From fcb959fdd2acf4fbc6c815e4d2386d00ad4ae9fd Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 25 Jun 2010 09:01:41 +0000 Subject: [PATCH] * Fixed the makefile to only run enabled tests, instead of every file in the directory with "test" in its name. Did this by moving the test list to a common PHP file, accessible by both the makefile and a new PHPUnit_TextUI_Command subclass. * Removed the perl dependency from the default "make test". There doesn't seem to be a memory issue anymore, but you can always use one of the non-default targets if it recurs. * Fixed a couple of test/suite names broken in r68544. * Added custom CSS to Special:Selenium, accidentally missing from r68555. --- includes/specials/SpecialSelenium.php | 1 + maintenance/tests/Makefile | 35 ++++++++++++++--------- maintenance/tests/MediaWikiParserTest.php | 1 + maintenance/tests/ParserHelpers.php | 4 +++ maintenance/tests/TestFileList.php | 30 +++++++++++++++++++ maintenance/tests/phpunit | 14 ++++++++- maintenance/tests/phpunit.xml | 32 ++------------------- 7 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 maintenance/tests/TestFileList.php diff --git a/includes/specials/SpecialSelenium.php b/includes/specials/SpecialSelenium.php index 442c2806c0..93d57ca220 100644 --- a/includes/specials/SpecialSelenium.php +++ b/includes/specials/SpecialSelenium.php @@ -48,6 +48,7 @@ class SpecialSelenium extends SpecialPage { $result = new PHPUnit_Framework_TestResult; $logger = new SeleniumTestHTMLLogger; $result->addListener( new SeleniumTestListener( $logger ) ); + $logger->setHeaders(); // run tests $suite = new SeleniumTestSuite; diff --git a/maintenance/tests/Makefile b/maintenance/tests/Makefile index e35ecc6ca9..ece423cf69 100644 --- a/maintenance/tests/Makefile +++ b/maintenance/tests/Makefile @@ -1,23 +1,32 @@ -# See -# http://lists.wikimedia.org/pipermail/wikitech-l/2010-February/046657.html -# for why prove(1) is the default target and not phpunit(1) +# If you have problems with excessive memory usage, use the "tap" or "separate" targets. -.PHONY: help test -all test: tap +TEST_FILES=$(shell php -r 'include( "./TestFileList.php" ); echo implode( " ", $$testFiles );') +TEST_FILE_TARGETS=$(subst .php,.target,$(TEST_FILES)) -tap: - prove -e 'php phpunit.php --tap' *Test*.php +.PHONY: help test phpunit tap separate install $(TEST_FILE_TARGETS) + +all test: phpunit phpunit: - phpunit + php phpunit + +tap: + prove -e 'php phpunit --tap' *Test*.php + +separate: $(TEST_FILE_TARGETS) + +# Need --tap because without it, the target specification doesn't work +$(TEST_FILE_TARGETS) : %.target : %.php + php phpunit --tap $< install: pear channel-discover pear.phpunit.de pear install phpunit/PHPUnit help: - # Options: - # test (default) Run the tests individually through Test::Harness's prove(1) - # phpunit Run all the tests with phpunit - # install Install PHPUnit from phpunit.de - # help You're looking at it! + # Targets: + # phpunit (default) Run all the tests with phpunit + # separate Run each test file in a separate process + # tap Run the tests individually through Test::Harness's prove(1) + # install Install PHPUnit from phpunit.de + # help You're looking at it! diff --git a/maintenance/tests/MediaWikiParserTest.php b/maintenance/tests/MediaWikiParserTest.php index ebeffd66a4..0410a96918 100644 --- a/maintenance/tests/MediaWikiParserTest.php +++ b/maintenance/tests/MediaWikiParserTest.php @@ -11,6 +11,7 @@ class MediaWikiParserTestSuite extends PHPUnit_Framework_TestSuite { public function __construct() { $this->backend = new ParserTestSuiteBackend; parent::__construct(); + $this->setName( 'Parser tests' ); } public function run( PHPUnit_Framework_TestResult $result = null, $filter = false, diff --git a/maintenance/tests/ParserHelpers.php b/maintenance/tests/ParserHelpers.php index 3288df8263..ec73402d31 100644 --- a/maintenance/tests/ParserHelpers.php +++ b/maintenance/tests/ParserHelpers.php @@ -49,6 +49,10 @@ class ParserUnitTest extends PHPUnit_Framework_TestCase { return $result; } + public function toString() { + return $this->test['test']; + } + } class ParserTestSuiteBackend extends ParserTest { diff --git a/maintenance/tests/TestFileList.php b/maintenance/tests/TestFileList.php new file mode 100644 index 0000000000..f3d86ff4bc --- /dev/null +++ b/maintenance/tests/TestFileList.php @@ -0,0 +1,30 @@ +addTestFile( $file ); + } + $suite->setName( 'MediaWiki test suite' ); + $this->arguments['test'] = $suite; + } +} + +$command = new MWPHPUnitCommand; $command->run( $argv ); diff --git a/maintenance/tests/phpunit.xml b/maintenance/tests/phpunit.xml index 1cf7277fea..d7eeda4837 100644 --- a/maintenance/tests/phpunit.xml +++ b/maintenance/tests/phpunit.xml @@ -5,36 +5,8 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - stopOnFailure="false"> - - - - - CdbTest.php - DatabaseSqliteTest.php - DatabaseTest.php - GlobalTest.php - - IPTest.php - ImageFunctionsTest.php - LanguageConverterTest.php - LicensesTest.php - LocalFileTest.php - MediaWikiParserTest.php - MessageTest.php - RevisionTest.php - SanitizerTest.php - SearchDbTest.php - SearchEngineTest.php - SearchUpdateTest.php - SiteConfigurationTest.php - TimeAdjustTest.php - TitlePermissionTest.php - TitleTest.php - UploadTest.php - UploadFromUrlTestSuite.php - XmlTest.php - + stopOnFailure="false"> + Broken -- 2.20.1