Hi everyone,
Started poking on parser tests lately and found myself riddled after a while. It seems like when running parser test files with phpunit.php they follow different rules as when running them with parserTests.php.
If I observed this correctly, phpunit.php collects all articles to be created with "!!article", creates them, and then it runs tests. With parserTests.php on the other hand everything is executed in the order it is defined. In some tests it can be important whether a article already exists or not. There might be other behavioral differences here as well. The whole thing seems incredibly odd to me since there is also some redundant code and the initial globals set up in ParserTest::setupGlobals() are slightly different from globals set up in NewParserTest::setupGlobals(). If there is no good reason against this, both classes, ParserTest and NewParserTest should be reduced to one, or at least one base class/interface. The goal should be that when running phpunit.php parser tests behave exactly like running parserTests.php
Already created a bug report for this as well, it just didn't get any attention so far, so I try it here: https://bugzilla.wikimedia.org/show_bug.cgi?id=39473
I would very much appreciate if anyone could explain to me why there are both of these files and why we maintain (more or less) a whole bunch of redundant code for those tests.
Cheers, Daniel
On Fri, Aug 31, 2012 at 7:01 AM, Daniel Werner daniel.werner@wikimedia.de wrote:
Hi everyone,
Started poking on parser tests lately and found myself riddled after a while. It seems like when running parser test files with phpunit.php they follow different rules as when running them with parserTests.php.
If I observed this correctly, phpunit.php collects all articles to be created with "!!article", creates them, and then it runs tests. With parserTests.php on the other hand everything is executed in the order it is defined. In some tests it can be important whether a article already exists or not. There might be other behavioral differences here as well. The whole thing seems incredibly odd to me since there is also some redundant code and the initial globals set up in ParserTest::setupGlobals() are slightly different from globals set up in NewParserTest::setupGlobals(). If there is no good reason against this, both classes, ParserTest and NewParserTest should be reduced to one, or at least one base class/interface. The goal should be that when running phpunit.php parser tests behave exactly like running parserTests.php
Already created a bug report for this as well, it just didn't get any attention so far, so I try it here: https://bugzilla.wikimedia.org/show_bug.cgi?id=39473
I would very much appreciate if anyone could explain to me why there are both of these files and why we maintain (more or less) a whole bunch of redundant code for those tests.
Cheers, Daniel
-- Daniel Werner Software Engineer
Wikimedia Deutschland e.V. | NEU: Obentrautstr. 72 | 10963 Berlin Tel. (030) 219 158 26-0
Wikimedia Deutschland - Gesellschaft zur Förderung Freien Wissens e.V. Eingetragen im Vereinsregister des Amtsgerichts Berlin-Charlottenburg unter der Nummer 23855 B. Als gemeinnützig anerkannt durch das Finanzamt für Körperschaften I Berlin, Steuernummer 27/681/51985. _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
I don't know why it is like it is, but I have noticed that the parser tests I wrote for DynamicPageList (Wikimedia) only work when run from parserTests.php and not when run from phpunit. It would be awesome if they behaved the same.
--bawolff
On 31/08/12 12:01, Daniel Werner wrote:
Hi everyone,
Started poking on parser tests lately and found myself riddled after a while. It seems like when running parser test files with phpunit.php they follow different rules as when running them with parserTests.php.
If I observed this correctly, phpunit.php collects all articles to be created with "!!article", creates them, and then it runs tests. With parserTests.php on the other hand everything is executed in the order it is defined. In some tests it can be important whether a article already exists or not.
That was done for creating the "articles" once, outside of the test loop. Originally they were also created in place, but inserting all articles for each test was really slow.
If a test relies on some articles existing, those should be defined before it. If it's not documented, it should be. With that rule in place, the difference on creating at the start or on demand doesn't matter.
(...)
I would very much appreciate if anyone could explain to me why there are both of these files and why we maintain (more or less) a whole bunch of redundant code for those tests.
Cheers, Daniel
Someone did a crappy work when creating the phpunit parser tests, duplicating a lot of code and sharing none between them. It was later improved by several people, as years passed, I did myself several fixes to the phpunit code. I think it is easy to compare them with a visual diff tool. I remember that some more methods could be shared if the parameter order of parserTests.php was changed.
Best regards
I remember that some more methods could be shared if the
parameter order of parserTests.php was changed Not sure whether params order has to change but yest, more code there could be shared. No idea why the localsettings are not shared for example.
That was done for creating the "articles" once, outside of the test loop. Originally they were also created in place, but inserting all articles for each test was really slow.
Ok, here is why I want articles to be created in-between tests, within the test loop: http://pastebin.com/g694dG6L Also, I want to change the local settings before creating certain articles, to create them with lower-case characters for some tests. I would suggest taking the lost in performance into account for that, it gives more flexibility for the tests. Or do are there any other ideas?
Also see my patch-set https://gerrit.wikimedia.org/r/#/c/20534/ which is blocked by this problem, here I wanted to introduce the "!!config" sections into "!!article". " !!config" is also something new I have introduced to parser tests in case you haven't seen it yet.
Cheers, Daniel
2012/9/1 Platonides Platonides@gmail.com
On 31/08/12 12:01, Daniel Werner wrote:
Hi everyone,
Started poking on parser tests lately and found myself riddled after a while. It seems like when running parser test files with phpunit.php they follow different rules as when running them with parserTests.php.
If I observed this correctly, phpunit.php collects all articles to be created with "!!article", creates them, and then it runs tests. With parserTests.php on the other hand everything is executed in the order it
is
defined. In some tests it can be important whether a article already
exists
or not.
That was done for creating the "articles" once, outside of the test loop. Originally they were also created in place, but inserting all articles for each test was really slow.
If a test relies on some articles existing, those should be defined before it. If it's not documented, it should be. With that rule in place, the difference on creating at the start or on demand doesn't matter.
(...)
I would very much appreciate if anyone could explain to me why there are both of these files and why we maintain (more or less) a whole bunch of redundant code for those tests.
Cheers, Daniel
Someone did a crappy work when creating the phpunit parser tests, duplicating a lot of code and sharing none between them. It was later improved by several people, as years passed, I did myself several fixes to the phpunit code. I think it is easy to compare them with a visual diff tool. I remember that some more methods could be shared if the parameter order of parserTests.php was changed.
Best regards
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org