Page MenuHomePhabricator

phpcs doesn't work with mediawiki/vendor repo, while phpunit fails with composer-managed vendor.
Open, Needs TriagePublic

Description

If I use the mediwiki/vendor repo to supply dependencies, I get the following:

$ phpcs 
PHP Fatal error:  Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff "vendor/mediawiki/mediawiki-codesniffer/MediaWiki" does not exist' in /usr/share/php/PHP/CodeSniffer.php:1092
Stack trace:
#0 /usr/share/php/PHP/CodeSniffer.php(733): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement), '/usr/local/src/...', 0)
#1 /usr/share/php/PHP/CodeSniffer.php(551): PHP_CodeSniffer->processRuleset('/usr/local/src/...')
#2 /usr/share/php/PHP/CodeSniffer/CLI.php(818): PHP_CodeSniffer->initStandard(Array, Array)
#3 /usr/share/php/PHP/CodeSniffer/CLI.php(95): PHP_CodeSniffer_CLI->process()
#4 /usr/bin/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /usr/share/php/PHP/CodeSniffer.php on line 1092

Apparently mediawiki/vendor doesn't include whatever dependencies are needed to run phpcs. Now that phpcs is voting, it's a pain not to be able to run it locally.

If instead I use composer to install dependencies, phpcs works but phpunit fails some tests! For example:

$ php tests/phpunit/phpunit.php --configuration tests/phpunit/suite.xml tests/phpunit/includes/exception/ErrorPageErrorTest.php 
PHPUnit already present
PHPUnit 3.7.37 by Sebastian Bergmann.

Configuration read from /usr/local/src/MediaWiki/core/tests/phpunit/suite.xml

EE.

Time: 124 ms, Memory: 13.25Mb

There were 2 errors:

1) ErrorPageErrorTest::testConstruction
Erroneous data format for unserializing 'Mock_Message_e3de1385'

/usr/local/src/MediaWiki/core/tests/phpunit/includes/exception/ErrorPageErrorTest.php:12
/usr/local/src/MediaWiki/core/tests/phpunit/includes/exception/ErrorPageErrorTest.php:23
/usr/local/src/MediaWiki/core/tests/phpunit/MediaWikiTestCase.php:137

2) ErrorPageErrorTest::testReport
Erroneous data format for unserializing 'Mock_Message_e3de1385'

/usr/local/src/MediaWiki/core/tests/phpunit/includes/exception/ErrorPageErrorTest.php:12
/usr/local/src/MediaWiki/core/tests/phpunit/includes/exception/ErrorPageErrorTest.php:33
/usr/local/src/MediaWiki/core/tests/phpunit/MediaWikiTestCase.php:137

FAILURES!
Tests: 3, Assertions: 1, Errors: 2.

With composer-managed vendor, it uses the ancient version of phpunit we have composer install. Which apparently has the issue described in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=762095, phpunit-mock-objects 1.2.3 doesn't work with PHP 5.6.

Event Timeline

Anomie created this task.Oct 8 2015, 5:41 PM
Anomie raised the priority of this task from to Needs Triage.
Anomie updated the task description. (Show Details)
Anomie added projects: Composer, MediaWiki-Vendor.
Anomie added a subscriber: Anomie.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 8 2015, 5:41 PM
bd808 added a subscriber: bd808.Oct 8 2015, 5:59 PM

Yet another reason to find a fix for T112895: Support installing composer require-dev packages together with mediawiki/vendor so we can bump that PHPUnit version in core and run something modern.

polybuildr added a subscriber: polybuildr.

$ phpcs

This isn't from mediawiki/vendor, it's probably from a system package.

$ phpcs

This isn't from mediawiki/vendor, it's probably from a system package.

So? It works with composer-managed dependencies, and doesn't with mediawiki/vendor.

What's your preferred way to run phpcs tests when using mediawiki/vendor, instead of having to submit it and then read the Jenkins/Zuul output?

Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptDec 15 2015, 11:10 PM