From: Timo Tijhof Date: Sat, 6 Apr 2019 22:53:30 +0000 (+0100) Subject: phpunit: Don't include PHPUnitCommand channel in MediaWikiLoggerPHPUnitTestListener X-Git-Tag: 1.34.0-rc.0~2105^2~2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=d9891f872f9d92f7109d7c6b9fcb6894e4c083bc;p=lhc%2Fweb%2Fwiklou.git phpunit: Don't include PHPUnitCommand channel in MediaWikiLoggerPHPUnitTestListener Follows-up 96657099fc (T217489) adding MediaWikiLoggerPHPUnitTestListener. It started printing messages from log channels to CLI output when there is one or more failed assertions. This is useful. But, it also interacts with MediaWikiPHPUnitTestListener from 2018, which calls wfDebugLog('PHPUnitCommand', …) for every test and every assertion. That allows one to later open debug.log and see MediaWiki's messages interleaved with PHPUnit activity. This provides messages from a much larger scope (including before test setup, and data providers). But, this means we get: > There were N failures: > 1) ExampleTest::testGetThing > === Logs generated by test case > [PHPUnitCommand] [info] FAILURE in ExampleTest::testGetThing: > [PHPUnit\Framework\ExpectationFailedException] Failed asserting … > … > … > … > … {"private":false} > === > Failed asserting that … > --- Expected > +++ Actual > @@ @@ > … > /var/www/mediawiki/tests/phpunit/includes/…:… This needlessly repeats the test name and method, and takes up vertical space to describe the failed assertion in a way that is less useful than the one that PHPUnit already prints after it. Exclude these by default from CLI. Bug: T217489 Change-Id: I0f471f82b16ba869d15389ed470bd73dc6deea78 --- diff --git a/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php b/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php index f87afb0471..8f3418077b 100644 --- a/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php +++ b/tests/phpunit/MediaWikiLoggerPHPUnitTestListener.php @@ -83,6 +83,11 @@ class MediaWikiLoggerPHPUnitTestListener extends PHPUnit_Framework_BaseTestListe private function formatLogs( array $logs ) { $message = []; foreach ( $logs as $log ) { + if ( $log['channel'] === 'PHPUnitCommand' ) { + // Don't print the log of PHPUnit events while running PHPUnit, + // because PHPUnit is already printing those already. + continue; + } $message[] = sprintf( '[%s] [%s] %s %s', $log['channel'],