2012/4/19 Patrick Ohly <[email protected]>: > On Wed, 2012-04-18 at 12:51 +0200, Krzesimir Nowak wrote: >> I added some more tests, they are as usual on my branch: >> https://meego.gitorious.org/~krnowak/meego-middleware/krnowaks-syncevolution/commits/cmdline-tests-master > > When you move tests, can you also copy the comments associated with > them? For example: > > void testPrintFileTemplates() { > // use local copy of templates in build dir (no need to install) > ScopedEnvChange templates("SYNCEVOLUTION_TEMPLATE_DIR", "./templates"); > > The comment in the C++ version explains (briefly) what "./templates" is > meant to be: the "src/templates" that gets created in the build > directory. The (admittedly undocumented) assumption is that test-dbus.py > will always be run there. > > The Python version replicates that without the comment: > > # TODO: this test works, but I do not know what are the assumptions behind it. > @property("ENV", "SYNCEVOLUTION_TEMPLATE_DIR=./templates") > @property("debug", False) > def testPrintFileTemplates(self): > """TestCmdline.testPrintFileTemplates - print file templates""" > self.doPrintFileTemplates() > >> testPrintFileTemplatesConfig is fishy for me and fails with an error >> for now. There is a TODO about it. Could you look at it? > > The Python version doesn't quite match the C++ version. self.configdir = > $XDG_CONFIG_HOME/syncevolution != m_testDir = $XDG_CONFIG_HOME. > > Here's a patch which makes the test work: > > diff --git a/test/test-dbus.py b/test/test-dbus.py > index 5adea8f..fafe974 100755 > --- a/test/test-dbus.py > +++ b/test/test-dbus.py > @@ -4379,19 +4379,30 @@ sources/todo/config.ini:# databasePassword = > '''.format( > > self.assertEqualDiff(filterConfig(internalToIni(self.FunambolConfig())), > injectValues(filterConfig(out))) > > -# TODO: this test works, but I do not know what are the assumptions behind > it. > + # Use local copy of templates in build dir (no need to install); > + # this assumes that test-dbus.py is run in the build "src" > + # directory. > @property("ENV", "SYNCEVOLUTION_TEMPLATE_DIR=./templates") > @property("debug", False) > def testPrintFileTemplates(self): > """TestCmdline.testPrintFileTemplates - print file templates""" > self.doPrintFileTemplates() > > + # Disable reading default templates, rely on finding the user > + # ones (set up below via symlink). > @property("ENV", "SYNCEVOLUTION_TEMPLATE_DIR=/dev/null") > @property("debug", False) > def testPrintFileTemplatesConfig(self): > - """TestCmdline.testPrintFileTemplatesConfig - print file templates > config""" > -# TODO: This "../templates" looks fishy. I do not know what are the > assumptions behind it. > - os.symlink("../templates", self.configdir + > "/syncevolution-templates") > + """TestCmdline.testPrintFileTemplatesConfig - print file templates > from user home directory""" > + # The user's "home directory" or more precisely, his > + # XDG_CONFIG_HOME, is set to xdg_root + "config". Make sure > + # that there is a "syncevolution-templates" with valid > + # templates in that "config" directory, because "templates" > + # will not be found otherwise (SYNCEVOLUTION_TEMPLATE_DIR > + # doesn't point to it). > + os.makedirs(xdg_root + "/config") > + # Use same "./templates" as in testPrintFileTemplates(). > + os.symlink("../../templates", xdg_root + > "/config/syncevolution-templates") > self.doPrintFileTemplates() > > @property("debug", False) > > >> Also, there are some TODOs in testSync. Maybe some --print-config + >> some parameters could mimick the C++ code there? > > I think the parts marked with TODO are examples of tests that better > stays in Cmdline.cpp because they are true unit tests (cover internal > implementation aspects). >
Small status update: I got a sort of hickup, because suddenly tests stopped working - running syncevolution via process subprocess module caused it to hang, so tests were ending with errors after timeout. After googling a bit about it I thought that using pipes to gather output from syncevolution is the culprit - a deadlock may happen when output is so large that it fills the pipe completely, so subprocess is blocked during writing, because it waits for the pipe to be empty. Pipes are emptied by reading from them, but that happen only after subprocess finishes. But apparently that was not that - I changed runCmdline to use just files, but hanging still happened. I tried running tests after setting minimal environment needed for running the tests (PATH and SYNCEVOLUTION_TEMPLATE_DIR) and the tests worked. It turned out that G_SLICE env var set to "always-malloc" was messing something up. What? I do not know and I was not investigating it - I have lost too much time on it already. Currently tests are in cmdline-tests-master branch which is rebased against today's master: https://meego.gitorious.org/~krnowak/meego-middleware/krnowaks-syncevolution/commits/cmdline-tests-master (you will most probably get "503 Service Unavailable", I wonder when word "gitorious" will hit the common directory as a synonym of being crappy, slow or other negative adjectives) Tests not ported: testFutureConfig testPeerConfigMigration testContextConfigMigration testOldConfigure Tests failing on my computer: testConfigureSource: AssertionError: differences between expected and actual text .internal.ini:contextMinVersion = 1 .internal.ini:contextCurVersion = 1 config.ini:# logdir = config.ini:# maxlogdirs = 10 config.ini:deviceId = fixed-devid sources/addressbook/config.ini:backend = file sources/addressbook/config.ini:database = file://tmp/test - sources/addressbook/config.ini:databaseFormat = text/x-vcard ? ---- + sources/addressbook/config.ini:databaseFormat = /x-vcard sources/addressbook/config.ini:# databaseUser = sources/addressbook/config.ini:# databasePassword = ======== testItemOperations: AssertionError: differences between expected and actual text - BEGIN:VCARD + BEGIN - VERSION:3.0 ? ---- + VERSION - FN:John Doe - N:Doe;John;;; - END:VCARD + FN + N + END - BEGIN:VCARD + BEGIN - VERSION:3.0 ? ---- + VERSION - FN:Joan Doe - N:Doe;Joan;;; - END:VCARD + FN + N + END ======== testMigrate and testMigrateAutoSync: AssertionError: syncevolution command failed. Output: Separate stderr: [ERROR] Server 'scheduleworld@default' has not been configured yet. ======== testMigrateContext: AssertionError: 'sources/addressbook/config.ini:databaseFormat = text/vcard' not found in 'long long text, will not paste it as a whole here' Relevant line of this ''long long text...' is: 'sources/addressbook/config.ini:# databaseFormat = ' ======== Also, testConfigure is failing without workarounds there - stripping the last newline from expected output. It is marked as 'WORKAROUND', so it is easy to grep. I have not yet removed the C++ tests. I guess that would be the next step, together with "proofcomparing" C++ and Python tests. > > -- > Best Regards, Patrick Ohly > > The content of this message is my personal opinion only and although > I am an employee of Intel, the statements I make here in no way > represent Intel's position on the issue, nor am I authorized to speak > on behalf of Intel on this matter. > > _______________________________________________ SyncEvolution mailing list [email protected] http://lists.syncevolution.org/listinfo/syncevolution
