Last modified: 2014-11-01 02:34:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T60881, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 58881 - Can't use phpunit.phar to invoke MediaWiki tests
Can't use phpunit.phar to invoke MediaWiki tests
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Unit tests (Other open bugs)
1.23.0
All All
: Normal critical (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 63690 64597 69048 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-12-23 05:14 UTC by Ori Livneh
Modified: 2014-11-01 02:34 UTC (History)
14 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Ori Livneh 2013-12-23 05:14:50 UTC
PHPUnit's manual recommends the PHPUnit phar as the easiest way to obtain PHPUnit and its dependencies. Unfortunately, when PHPUnit is loaded via a phar file, there appears to be no way to use it to run MediaWiki's test suites. If you try to execute the tests by invoking the phar file, MediaWiki's environment is not set up. If you attempt to use MediaWiki's own tests/phpunit/phpunit.php, you find that there is no way to get MediaWiki to resolve its includes / requires using the phar file: --with-phpunitdir could presumably add the phar file to include_path (which is supported by PHP, AFAIK), but it currently chokes on anything that isn't an actual directory.
Comment 1 Andrew Garrett 2014-03-14 05:30:39 UTC
As of a week ago, PHPUnit is distributed as a PHAR by PEAR (see <https://github.com/sebastianbergmann/phpunit/wiki/ChangeLog-for-PHPUnit-4.0>).

So this is now a really big issue.
Comment 2 Sebastian Bergmann 2014-03-14 07:14:58 UTC
The problem is that you are trying to include/require a source file of PHPUnit instead of relying on PHPUnit's class loader to load the class in question.
Comment 3 Gerrit Notification Bot 2014-03-16 23:27:04 UTC
Change 118997 had a related patch set uploaded by Aude:
Allow use of phpunit.phar with MediaWiki's phpunit.php test entry point

https://gerrit.wikimedia.org/r/118997
Comment 4 Aude 2014-03-16 23:28:20 UTC
this is a workaround but think it would be better to have our phpunit.php or whatever be includable via phpunit's --bootstrap parameter.
Comment 5 Gerrit Notification Bot 2014-03-16 23:36:42 UTC
Change 118997 had a related patch set uploaded by Aude:
Allow use of phpunit.phar with MediaWiki's phpunit.php test entry point

https://gerrit.wikimedia.org/r/118997
Comment 6 Gerrit Notification Bot 2014-03-16 23:43:50 UTC
Change 118997 had a related patch set uploaded by Aude:
Allow use of phpunit.phar with MediaWiki's phpunit.php test entry point

https://gerrit.wikimedia.org/r/118997
Comment 7 Aude 2014-03-17 11:00:28 UTC
my patch does not work correctly with the way MediaWiki extends PHPUnit_TextUI_Command in MediaWikiPHPUnitCommand.  It only works if one specifies no additional non-phpunit options.

the phpunit.phar executes PHPUnit_TextUI_Command::main();

I think the way to go is to have a proper bootstrap to use with phpunit's --bootstrap option
Comment 8 Aude 2014-03-17 12:00:11 UTC
question is...

if one extends PHPUnit_TextUI_Command (as phpunit source code suggests), then how is it recommended to have that work with phpunit.phar (which calls PHPUnit_TextUI_Command::main() )?
Comment 9 Sebastian Bergmann 2014-03-17 12:02:39 UTC
That is a valid question. To be honest, I have always discouraged extensions to PHPUnit_TextUI_Command (maybe I was not vocal/verbose enough about it).
Comment 10 Aude 2014-03-17 12:09:38 UTC
probably using the bootstrap option is the best approach then.
Comment 11 Kevin Israel (PleaseStand) 2014-04-08 18:08:06 UTC
*** Bug 63690 has been marked as a duplicate of this bug. ***
Comment 12 Marius Hoch 2014-05-05 09:24:33 UTC
Raising priority as this starts to cause real problems (eg. tests on travis no longer work for Wikibase due to this).
Comment 13 Addshore 2014-05-05 13:05:25 UTC
Some related changes starting to strip down MediaWikiPHPUnitCommand a bit..

https://gerrit.wikimedia.org/r/131448
https://gerrit.wikimedia.org/r/131450
https://gerrit.wikimedia.org/r/131454
https://gerrit.wikimedia.org/r/131456

The hardest thing to move / fix that I can see is the additional options that have been shoved into $additionalOptions
Comment 14 Addshore 2014-05-05 14:14:33 UTC
Also https://gerrit.wikimedia.org/r/131466
Comment 15 Addshore 2014-05-05 16:15:06 UTC
Also https://gerrit.wikimedia.org/r/#/c/131488 which removes MediaWikiPHPUnitCommand

https://gerrit.wikimedia.org/r/118997 should probably now be rebased on top of this chain
Comment 16 Addshore 2014-05-05 16:43:41 UTC
I have amended https://gerrit.wikimedia.org/r/#/c/118997/ and now the whole chain should be ready for review.
Comment 17 Antoine "hashar" Musso (WMF) 2014-08-02 14:31:45 UTC
*** Bug 69048 has been marked as a duplicate of this bug. ***
Comment 18 Antoine "hashar" Musso (WMF) 2014-08-02 14:32:53 UTC
*** Bug 64597 has been marked as a duplicate of this bug. ***
Comment 19 physikerwelt 2014-08-02 22:24:04 UTC
I could reproduce the problem hashar describes in
https://gerrit.wikimedia.org/r/#/c/131466/6
there is no color in the output with the option --debug-tests.
This could become a separate bug, or just fixed in one of the follow up commits.
I tried.. but i did not manage to fix it in 30 minutes so I gave up.
Comment 20 Gerrit Notification Bot 2014-08-02 22:50:08 UTC
Change 118997 merged by jenkins-bot:
Allow use of phpunit.phar with MediaWiki's phpunit.php test entry point

https://gerrit.wikimedia.org/r/118997
Comment 21 Gerrit Notification Bot 2014-08-03 09:05:19 UTC
Change 151394 had a related patch set uploaded by JanZerebecki:
phpunit.php: Allow direct use of a PHPUnit PHAR file.

https://gerrit.wikimedia.org/r/151394
Comment 22 Marius Hoch 2014-11-01 02:34:51 UTC
This bug as is, is resolved (you can now use the phpunit.phar for unit tests). If there are other issues (like using the phar is not nice, than create another bug, please).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links