Page MenuHomePhabricator

Generated parser test class names should be unique
Closed, ResolvedPublic

Description

Inside of an extension create a parser tests file, name it parserTests.txt, and use $wgParserTestFiles[] = DIR . '/parserTests.txt';

Running parserTests will work perfectly fine. However attempting to run unit tests will result in the following.

PHP Fatal error: Cannot redeclare class ParserTests in {core}/tests/phpunit/includes/parser/MediaWikiParserTest.php(27) : eval()'d code on line 3

It appears that the phpunit parser test code makes really generic class names for parser test files based on the filename alone completely ignoring different paths.


Version: unspecified
Severity: minor

Details

Reference
bz42174

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 1:10 AM
bzimport set Reference to bz42174.

Rephrased to Parsertests generated class names are not unique. See implementation in phpunit/includes/parser/MediaWikiParserTest.php which uses basename(). Definitely easy to fix, just have to find out a new convention.

Related URL: https://gerrit.wikimedia.org/r/67098 (Gerrit Change Idf14b4cbdb8ec103340d48855e0361acf707b101)

Thanks Bawolff for the patch, I just run into this as well.

PHP Fatal error: Cannot redeclare class ParserTests in /srv/vagrant/mediawiki/tests/phpunit/includes/parser/MediaWikiParserTest.php(106) : eval()'d code on line 9
PHP Stack trace:
PHP 1. {main}() /srv/vagrant/mediawiki/tests/phpunit/phpunit.php:0
PHP 2. MediaWikiPHPUnitCommand::main() /srv/vagrant/mediawiki/tests/phpunit/phpunit.php:160
PHP 3. PHPUnit_TextUI_Command->run() /srv/vagrant/mediawiki/tests/phpunit/MediaWikiPHPUnitCommand.php:42
PHP 4. MediaWikiPHPUnitCommand->handleArguments() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:138
PHP 5. PHPUnit_TextUI_Command->handleArguments() /srv/vagrant/mediawiki/tests/phpunit/MediaWikiPHPUnitCommand.php:25
PHP 6. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:657
PHP 7. PHPUnit_Util_Configuration->getTestSuite() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php:797
PHP 8. PHPUnit_Framework_TestSuite->addTestFile() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Util/Configuration.php:912
PHP 9. ReflectionMethod->invoke() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:382
PHP 10. ExtensionsParserTestSuite::suite() /srv/vagrant/mediawiki/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:382
PHP 11. MediaWikiParserTest::suite() /srv/vagrant/mediawiki/tests/phpunit/suites/ExtensionsParserTestSuite.php:5

Fatal error: Cannot redeclare class ParserTests in /srv/vagrant/mediawiki/tests/phpunit/includes/parser/MediaWikiParserTest.php(106) : eval()'d code on line 9

Change 67098 merged by jenkins-bot:
Make generating Parser test class names more robust

https://gerrit.wikimedia.org/r/67098

Reedy CR ftw