r82874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82873‎ | r82874 | r82875 >
Date:23:36, 26 February 2011
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Readding parserTests.php and testHelpers.inc with history back to r73884 when they had also been moved without telling svn about it.
Follow up to r78389 and r82873.
Modified paths:
  • /trunk/phase3/tests/parserTests.php (added) (history)
  • /trunk/phase3/tests/testHelpers.inc (added) (history)

Diff [purge]

Index: trunk/phase3/tests/parserTests.php
@@ -0,0 +1,91 @@
 2+<?php
 3+/**
 4+ * MediaWiki parser test suite
 5+ *
 6+ * Copyright © 2004 Brion Vibber <brion@pobox.com>
 7+ * http://www.mediawiki.org/
 8+ *
 9+ * This program is free software; you can redistribute it and/or modify
 10+ * it under the terms of the GNU General Public License as published by
 11+ * the Free Software Foundation; either version 2 of the License, or
 12+ * (at your option) any later version.
 13+ *
 14+ * This program is distributed in the hope that it will be useful,
 15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 17+ * GNU General Public License for more details.
 18+ *
 19+ * You should have received a copy of the GNU General Public License along
 20+ * with this program; if not, write to the Free Software Foundation, Inc.,
 21+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 22+ * http://www.gnu.org/copyleft/gpl.html
 23+ *
 24+ * @file
 25+ * @ingroup Maintenance
 26+ */
 27+
 28+$options = array( 'quick', 'color', 'quiet', 'help', 'show-output', 'record', 'run-disabled' );
 29+$optionsWithArgs = array( 'regex', 'seed', 'setversion' );
 30+
 31+require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
 32+
 33+if ( isset( $options['help'] ) ) {
 34+ echo <<<ENDS
 35+MediaWiki $wgVersion parser test suite
 36+Usage: php parserTests.php [options...]
 37+
 38+Options:
 39+ --quick Suppress diff output of failed tests
 40+ --quiet Suppress notification of passed tests (shows only failed tests)
 41+ --show-output Show expected and actual output
 42+ --color[=yes|no] Override terminal detection and force color output on or off
 43+ use wgCommandLineDarkBg = true; if your term is dark
 44+ --regex Only run tests whose descriptions which match given regex
 45+ --file=<testfile> Run test cases from a custom file instead of parserTests.txt
 46+ --record Record tests in database
 47+ --compare Compare with recorded results, without updating the database.
 48+ --setversion When using --record, set the version string to use (useful
 49+ with git-svn so that you can get the exact revision)
 50+ --keep-uploads Re-use the same upload directory for each test, don't delete it
 51+ --fuzz Do a fuzz test instead of a normal test
 52+ --seed <n> Start the fuzz test from the specified seed
 53+ --help Show this help message
 54+ --run-disabled run disabled tests
 55+ --upload Upload test results to remote wiki (per \$wgParserTestRemote)
 56+
 57+ENDS;
 58+ exit( 0 );
 59+}
 60+
 61+# Cases of weird db corruption were encountered when running tests on earlyish
 62+# versions of SQLite
 63+if ( wfGetDB( DB_MASTER )->getType() == 'sqlite' ) {
 64+ $version = wfGetDB( DB_MASTER )->getServerVersion();
 65+ if ( version_compare( $version, '3.6' ) < 0 ) {
 66+ die( "Parser tests require SQLite version 3.6 or later, you have $version\n" );
 67+ }
 68+}
 69+
 70+# There is a convention that the parser should never
 71+# refer to $wgTitle directly, but instead use the title
 72+# passed to it.
 73+$wgTitle = Title::newFromText( 'Parser test script do not use' );
 74+$tester = new ParserTest($options);
 75+
 76+if ( isset( $options['file'] ) ) {
 77+ $files = array( $options['file'] );
 78+} else {
 79+ // Default parser tests and any set from extensions or local config
 80+ $files = $wgParserTestFiles;
 81+}
 82+
 83+# Print out software version to assist with locating regressions
 84+$version = SpecialVersion::getVersion();
 85+echo( "This is MediaWiki version {$version}.\n\n" );
 86+
 87+if ( isset( $options['fuzz'] ) ) {
 88+ $tester->fuzzTest( $files );
 89+} else {
 90+ $ok = $tester->runTestsFromFiles( $files );
 91+ exit ( $ok ? 0 : 1 );
 92+}
Property changes on: trunk/phase3/tests/parserTests.php
___________________________________________________________________
Added: svn:mergeinfo
193 Merged /branches/phpunit-restructure/maintenance/tests/parserTests.php:r72257-72560
Added: svn:eol-style
294 + native
Added: svn:keywords
395 + Author Date Id Revision
Index: trunk/phase3/tests/testHelpers.inc
@@ -0,0 +1,651 @@
 2+<?php
 3+
 4+/**
 5+ * @ingroup Maintenance
 6+ *
 7+ * Set of classes to help with test output and such. Right now pretty specific
 8+ * to the parser tests but could be more useful one day :)
 9+ *
 10+ * @todo Fixme: Make this more generic
 11+ */
 12+
 13+class AnsiTermColorer {
 14+ function __construct() {
 15+ }
 16+
 17+ /**
 18+ * Return ANSI terminal escape code for changing text attribs/color
 19+ *
 20+ * @param $color String: semicolon-separated list of attribute/color codes
 21+ * @return String
 22+ */
 23+ public function color( $color ) {
 24+ global $wgCommandLineDarkBg;
 25+
 26+ $light = $wgCommandLineDarkBg ? "1;" : "0;";
 27+
 28+ return "\x1b[{$light}{$color}m";
 29+ }
 30+
 31+ /**
 32+ * Return ANSI terminal escape code for restoring default text attributes
 33+ *
 34+ * @return String
 35+ */
 36+ public function reset() {
 37+ return $this->color( 0 );
 38+ }
 39+}
 40+
 41+/* A colour-less terminal */
 42+class DummyTermColorer {
 43+ public function color( $color ) {
 44+ return '';
 45+ }
 46+
 47+ public function reset() {
 48+ return '';
 49+ }
 50+}
 51+
 52+class TestRecorder {
 53+ var $parent;
 54+ var $term;
 55+
 56+ function __construct( $parent ) {
 57+ $this->parent = $parent;
 58+ $this->term = $parent->term;
 59+ }
 60+
 61+ function start() {
 62+ $this->total = 0;
 63+ $this->success = 0;
 64+ }
 65+
 66+ function record( $test, $result ) {
 67+ $this->total++;
 68+ $this->success += ( $result ? 1 : 0 );
 69+ }
 70+
 71+ function end() {
 72+ // dummy
 73+ }
 74+
 75+ function report() {
 76+ if ( $this->total > 0 ) {
 77+ $this->reportPercentage( $this->success, $this->total );
 78+ } else {
 79+ wfDie( "No tests found.\n" );
 80+ }
 81+ }
 82+
 83+ function reportPercentage( $success, $total ) {
 84+ $ratio = wfPercent( 100 * $success / $total );
 85+ print $this->term->color( 1 ) . "Passed $success of $total tests ($ratio)... ";
 86+
 87+ if ( $success == $total ) {
 88+ print $this->term->color( 32 ) . "ALL TESTS PASSED!";
 89+ } else {
 90+ $failed = $total - $success ;
 91+ print $this->term->color( 31 ) . "$failed tests failed!";
 92+ }
 93+
 94+ print $this->term->reset() . "\n";
 95+
 96+ return ( $success == $total );
 97+ }
 98+}
 99+
 100+class DbTestPreviewer extends TestRecorder {
 101+ protected $lb; // /< Database load balancer
 102+ protected $db; // /< Database connection to the main DB
 103+ protected $curRun; // /< run ID number for the current run
 104+ protected $prevRun; // /< run ID number for the previous run, if any
 105+ protected $results; // /< Result array
 106+
 107+ /**
 108+ * This should be called before the table prefix is changed
 109+ */
 110+ function __construct( $parent ) {
 111+ parent::__construct( $parent );
 112+
 113+ $this->lb = wfGetLBFactory()->newMainLB();
 114+ // This connection will have the wiki's table prefix, not parsertest_
 115+ $this->db = $this->lb->getConnection( DB_MASTER );
 116+ }
 117+
 118+ /**
 119+ * Set up result recording; insert a record for the run with the date
 120+ * and all that fun stuff
 121+ */
 122+ function start() {
 123+ parent::start();
 124+
 125+ if ( ! $this->db->tableExists( 'testrun' )
 126+ or ! $this->db->tableExists( 'testitem' ) )
 127+ {
 128+ print "WARNING> `testrun` table not found in database.\n";
 129+ $this->prevRun = false;
 130+ } else {
 131+ // We'll make comparisons against the previous run later...
 132+ $this->prevRun = $this->db->selectField( 'testrun', 'MAX(tr_id)' );
 133+ }
 134+
 135+ $this->results = array();
 136+ }
 137+
 138+ function record( $test, $result ) {
 139+ parent::record( $test, $result );
 140+ $this->results[$test] = $result;
 141+ }
 142+
 143+ function report() {
 144+ if ( $this->prevRun ) {
 145+ // f = fail, p = pass, n = nonexistent
 146+ // codes show before then after
 147+ $table = array(
 148+ 'fp' => 'previously failing test(s) now PASSING! :)',
 149+ 'pn' => 'previously PASSING test(s) removed o_O',
 150+ 'np' => 'new PASSING test(s) :)',
 151+
 152+ 'pf' => 'previously passing test(s) now FAILING! :(',
 153+ 'fn' => 'previously FAILING test(s) removed O_o',
 154+ 'nf' => 'new FAILING test(s) :(',
 155+ 'ff' => 'still FAILING test(s) :(',
 156+ );
 157+
 158+ $prevResults = array();
 159+
 160+ $res = $this->db->select( 'testitem', array( 'ti_name', 'ti_success' ),
 161+ array( 'ti_run' => $this->prevRun ), __METHOD__ );
 162+
 163+ foreach ( $res as $row ) {
 164+ if ( !$this->parent->regex
 165+ || preg_match( "/{$this->parent->regex}/i", $row->ti_name ) )
 166+ {
 167+ $prevResults[$row->ti_name] = $row->ti_success;
 168+ }
 169+ }
 170+
 171+ $combined = array_keys( $this->results + $prevResults );
 172+
 173+ # Determine breakdown by change type
 174+ $breakdown = array();
 175+ foreach ( $combined as $test ) {
 176+ if ( !isset( $prevResults[$test] ) ) {
 177+ $before = 'n';
 178+ } elseif ( $prevResults[$test] == 1 ) {
 179+ $before = 'p';
 180+ } else /* if ( $prevResults[$test] == 0 )*/ {
 181+ $before = 'f';
 182+ }
 183+
 184+ if ( !isset( $this->results[$test] ) ) {
 185+ $after = 'n';
 186+ } elseif ( $this->results[$test] == 1 ) {
 187+ $after = 'p';
 188+ } else /*if ( $this->results[$test] == 0 ) */ {
 189+ $after = 'f';
 190+ }
 191+
 192+ $code = $before . $after;
 193+
 194+ if ( isset( $table[$code] ) ) {
 195+ $breakdown[$code][$test] = $this->getTestStatusInfo( $test, $after );
 196+ }
 197+ }
 198+
 199+ # Write out results
 200+ foreach ( $table as $code => $label ) {
 201+ if ( !empty( $breakdown[$code] ) ) {
 202+ $count = count( $breakdown[$code] );
 203+ printf( "\n%4d %s\n", $count, $label );
 204+
 205+ foreach ( $breakdown[$code] as $differing_test_name => $statusInfo ) {
 206+ print " * $differing_test_name [$statusInfo]\n";
 207+ }
 208+ }
 209+ }
 210+ } else {
 211+ print "No previous test runs to compare against.\n";
 212+ }
 213+
 214+ print "\n";
 215+ parent::report();
 216+ }
 217+
 218+ /**
 219+ * Returns a string giving information about when a test last had a status change.
 220+ * Could help to track down when regressions were introduced, as distinct from tests
 221+ * which have never passed (which are more change requests than regressions).
 222+ */
 223+ private function getTestStatusInfo( $testname, $after ) {
 224+ // If we're looking at a test that has just been removed, then say when it first appeared.
 225+ if ( $after == 'n' ) {
 226+ $changedRun = $this->db->selectField ( 'testitem',
 227+ 'MIN(ti_run)',
 228+ array( 'ti_name' => $testname ),
 229+ __METHOD__ );
 230+ $appear = $this->db->selectRow ( 'testrun',
 231+ array( 'tr_date', 'tr_mw_version' ),
 232+ array( 'tr_id' => $changedRun ),
 233+ __METHOD__ );
 234+
 235+ return "First recorded appearance: "
 236+ . date( "d-M-Y H:i:s", strtotime ( $appear->tr_date ) )
 237+ . ", " . $appear->tr_mw_version;
 238+ }
 239+
 240+ // Otherwise, this test has previous recorded results.
 241+ // See when this test last had a different result to what we're seeing now.
 242+ $conds = array(
 243+ 'ti_name' => $testname,
 244+ 'ti_success' => ( $after == 'f' ? "1" : "0" ) );
 245+
 246+ if ( $this->curRun ) {
 247+ $conds[] = "ti_run != " . $this->db->addQuotes ( $this->curRun );
 248+ }
 249+
 250+ $changedRun = $this->db->selectField ( 'testitem', 'MAX(ti_run)', $conds, __METHOD__ );
 251+
 252+ // If no record of ever having had a different result.
 253+ if ( is_null ( $changedRun ) ) {
 254+ if ( $after == "f" ) {
 255+ return "Has never passed";
 256+ } else {
 257+ return "Has never failed";
 258+ }
 259+ }
 260+
 261+ // Otherwise, we're looking at a test whose status has changed.
 262+ // (i.e. it used to work, but now doesn't; or used to fail, but is now fixed.)
 263+ // In this situation, give as much info as we can as to when it changed status.
 264+ $pre = $this->db->selectRow ( 'testrun',
 265+ array( 'tr_date', 'tr_mw_version' ),
 266+ array( 'tr_id' => $changedRun ),
 267+ __METHOD__ );
 268+ $post = $this->db->selectRow ( 'testrun',
 269+ array( 'tr_date', 'tr_mw_version' ),
 270+ array( "tr_id > " . $this->db->addQuotes ( $changedRun ) ),
 271+ __METHOD__,
 272+ array( "LIMIT" => 1, "ORDER BY" => 'tr_id' )
 273+ );
 274+
 275+ if ( $post ) {
 276+ $postDate = date( "d-M-Y H:i:s", strtotime ( $post->tr_date ) ) . ", {$post->tr_mw_version}";
 277+ } else {
 278+ $postDate = 'now';
 279+ }
 280+
 281+ return ( $after == "f" ? "Introduced" : "Fixed" ) . " between "
 282+ . date( "d-M-Y H:i:s", strtotime ( $pre->tr_date ) ) . ", " . $pre->tr_mw_version
 283+ . " and $postDate";
 284+
 285+ }
 286+
 287+ /**
 288+ * Commit transaction and clean up for result recording
 289+ */
 290+ function end() {
 291+ $this->lb->commitMasterChanges();
 292+ $this->lb->closeAll();
 293+ parent::end();
 294+ }
 295+
 296+}
 297+
 298+class DbTestRecorder extends DbTestPreviewer {
 299+ var $version;
 300+
 301+ /**
 302+ * Set up result recording; insert a record for the run with the date
 303+ * and all that fun stuff
 304+ */
 305+ function start() {
 306+ $this->db->begin();
 307+
 308+ if ( ! $this->db->tableExists( 'testrun' )
 309+ or ! $this->db->tableExists( 'testitem' ) )
 310+ {
 311+ print "WARNING> `testrun` table not found in database. Trying to create table.\n";
 312+ $this->db->sourceFile( $this->db->patchPath( 'patch-testrun.sql' ) );
 313+ echo "OK, resuming.\n";
 314+ }
 315+
 316+ parent::start();
 317+
 318+ $this->db->insert( 'testrun',
 319+ array(
 320+ 'tr_date' => $this->db->timestamp(),
 321+ 'tr_mw_version' => $this->version,
 322+ 'tr_php_version' => phpversion(),
 323+ 'tr_db_version' => $this->db->getServerVersion(),
 324+ 'tr_uname' => php_uname()
 325+ ),
 326+ __METHOD__ );
 327+ if ( $this->db->getType() === 'postgres' ) {
 328+ $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' );
 329+ } else {
 330+ $this->curRun = $this->db->insertId();
 331+ }
 332+ }
 333+
 334+ /**
 335+ * Record an individual test item's success or failure to the db
 336+ *
 337+ * @param $test String
 338+ * @param $result Boolean
 339+ */
 340+ function record( $test, $result ) {
 341+ parent::record( $test, $result );
 342+
 343+ $this->db->insert( 'testitem',
 344+ array(
 345+ 'ti_run' => $this->curRun,
 346+ 'ti_name' => $test,
 347+ 'ti_success' => $result ? 1 : 0,
 348+ ),
 349+ __METHOD__ );
 350+ }
 351+}
 352+
 353+class RemoteTestRecorder extends TestRecorder {
 354+ function start() {
 355+ parent::start();
 356+
 357+ $this->results = array();
 358+ $this->ping( 'running' );
 359+ }
 360+
 361+ function record( $test, $result ) {
 362+ parent::record( $test, $result );
 363+ $this->results[$test] = (bool)$result;
 364+ }
 365+
 366+ function end() {
 367+ $this->ping( 'complete', $this->results );
 368+ parent::end();
 369+ }
 370+
 371+ /**
 372+ * Inform a CodeReview instance that we've started or completed a test run...
 373+ *
 374+ * @param $status string: "running" - tell it we've started
 375+ * "complete" - provide test results array
 376+ * "abort" - something went horribly awry
 377+ * @param $results array of test name => true/false
 378+ */
 379+ function ping( $status, $results = false ) {
 380+ global $wgParserTestRemote, $IP;
 381+
 382+ $remote = $wgParserTestRemote;
 383+ $revId = SpecialVersion::getSvnRevision( $IP );
 384+ $jsonResults = FormatJson::encode( $results );
 385+
 386+ if ( !$remote ) {
 387+ print "Can't do remote upload without configuring \$wgParserTestRemote!\n";
 388+ exit( 1 );
 389+ }
 390+
 391+ // Generate a hash MAC to validate our credentials
 392+ $message = array(
 393+ $remote['repo'],
 394+ $remote['suite'],
 395+ $revId,
 396+ $status,
 397+ );
 398+
 399+ if ( $status == "complete" ) {
 400+ $message[] = $jsonResults;
 401+ }
 402+ $hmac = hash_hmac( "sha1", implode( "|", $message ), $remote['secret'] );
 403+
 404+ $postData = array(
 405+ 'action' => 'codetestupload',
 406+ 'format' => 'json',
 407+ 'repo' => $remote['repo'],
 408+ 'suite' => $remote['suite'],
 409+ 'rev' => $revId,
 410+ 'status' => $status,
 411+ 'hmac' => $hmac,
 412+ );
 413+
 414+ if ( $status == "complete" ) {
 415+ $postData['results'] = $jsonResults;
 416+ }
 417+
 418+ $response = $this->post( $remote['api-url'], $postData );
 419+
 420+ if ( $response === false ) {
 421+ print "CodeReview info upload failed to reach server.\n";
 422+ exit( 1 );
 423+ }
 424+
 425+ $responseData = FormatJson::decode( $response, true );
 426+
 427+ if ( !is_array( $responseData ) ) {
 428+ print "CodeReview API response not recognized...\n";
 429+ wfDebug( "Unrecognized CodeReview API response: $response\n" );
 430+ exit( 1 );
 431+ }
 432+
 433+ if ( isset( $responseData['error'] ) ) {
 434+ $code = $responseData['error']['code'];
 435+ $info = $responseData['error']['info'];
 436+ print "CodeReview info upload failed: $code $info\n";
 437+ exit( 1 );
 438+ }
 439+ }
 440+
 441+ function post( $url, $data ) {
 442+ return Http::post( $url, array( 'postData' => $data ) );
 443+ }
 444+}
 445+
 446+class TestFileIterator implements Iterator {
 447+ private $file;
 448+ private $fh;
 449+ private $parserTest; /* An instance of ParserTest (parserTests.php) or MediaWikiParserTest (phpunit) */
 450+ private $index = 0;
 451+ private $test;
 452+ private $lineNum;
 453+ private $eof;
 454+
 455+ function __construct( $file, $parserTest = null ) {
 456+ global $IP;
 457+
 458+ $this->file = $file;
 459+ $this->fh = fopen( $this->file, "rt" );
 460+
 461+ if ( !$this->fh ) {
 462+ wfDie( "Couldn't open file '$file'\n" );
 463+ }
 464+
 465+ $this->parserTest = $parserTest;
 466+
 467+ if ( $this->parserTest ) {
 468+ $this->parserTest->showRunFile( wfRelativePath( $this->file, $IP ) );
 469+ }
 470+
 471+ $this->lineNum = $this->index = 0;
 472+ }
 473+
 474+ function rewind() {
 475+ if ( fseek( $this->fh, 0 ) ) {
 476+ wfDie( "Couldn't fseek to the start of '$this->file'\n" );
 477+ }
 478+
 479+ $this->index = -1;
 480+ $this->lineNum = 0;
 481+ $this->eof = false;
 482+ $this->next();
 483+
 484+ return true;
 485+ }
 486+
 487+ function current() {
 488+ return $this->test;
 489+ }
 490+
 491+ function key() {
 492+ return $this->index;
 493+ }
 494+
 495+ function next() {
 496+ if ( $this->readNextTest() ) {
 497+ $this->index++;
 498+ return true;
 499+ } else {
 500+ $this->eof = true;
 501+ }
 502+ }
 503+
 504+ function valid() {
 505+ return $this->eof != true;
 506+ }
 507+
 508+ function readNextTest() {
 509+ $data = array();
 510+ $section = null;
 511+
 512+ while ( false !== ( $line = fgets( $this->fh ) ) ) {
 513+ $this->lineNum++;
 514+ $matches = array();
 515+
 516+ if ( preg_match( '/^!!\s*(\w+)/', $line, $matches ) ) {
 517+ $section = strtolower( $matches[1] );
 518+
 519+ if ( $section == 'endarticle' ) {
 520+ if ( !isset( $data['text'] ) ) {
 521+ wfDie( "'endarticle' without 'text' at line {$this->lineNum} of $this->file\n" );
 522+ }
 523+
 524+ if ( !isset( $data['article'] ) ) {
 525+ wfDie( "'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" );
 526+ }
 527+
 528+ if ( $this->parserTest ) {
 529+ $this->parserTest->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum );
 530+ } else {wfDie("JAJA");
 531+ ParserTest::addArticle( $data['article'], $data['text'], $this->lineNum );
 532+ }
 533+ $data = array();
 534+ $section = null;
 535+
 536+ continue;
 537+ }
 538+
 539+ if ( $section == 'endhooks' ) {
 540+ if ( !isset( $data['hooks'] ) ) {
 541+ wfDie( "'endhooks' without 'hooks' at line {$this->lineNum} of $this->file\n" );
 542+ }
 543+
 544+ foreach ( explode( "\n", $data['hooks'] ) as $line ) {
 545+ $line = trim( $line );
 546+
 547+ if ( $line ) {
 548+ if ( $this->parserTest && !$this->parserTest->requireHook( $line ) ) {
 549+ return false;
 550+ }
 551+ }
 552+ }
 553+
 554+ $data = array();
 555+ $section = null;
 556+
 557+ continue;
 558+ }
 559+
 560+ if ( $section == 'endfunctionhooks' ) {
 561+ if ( !isset( $data['functionhooks'] ) ) {
 562+ wfDie( "'endfunctionhooks' without 'functionhooks' at line {$this->lineNum} of $this->file\n" );
 563+ }
 564+
 565+ foreach ( explode( "\n", $data['functionhooks'] ) as $line ) {
 566+ $line = trim( $line );
 567+
 568+ if ( $line ) {
 569+ if ( $this->parserTest && !$this->parserTest->requireFunctionHook( $line ) ) {
 570+ return false;
 571+ }
 572+ }
 573+ }
 574+
 575+ $data = array();
 576+ $section = null;
 577+
 578+ continue;
 579+ }
 580+
 581+ if ( $section == 'end' ) {
 582+ if ( !isset( $data['test'] ) ) {
 583+ wfDie( "'end' without 'test' at line {$this->lineNum} of $this->file\n" );
 584+ }
 585+
 586+ if ( !isset( $data['input'] ) ) {
 587+ wfDie( "'end' without 'input' at line {$this->lineNum} of $this->file\n" );
 588+ }
 589+
 590+ if ( !isset( $data['result'] ) ) {
 591+ wfDie( "'end' without 'result' at line {$this->lineNum} of $this->file\n" );
 592+ }
 593+
 594+ if ( !isset( $data['options'] ) ) {
 595+ $data['options'] = '';
 596+ }
 597+
 598+ if ( !isset( $data['config'] ) )
 599+ $data['config'] = '';
 600+
 601+ if ( $this->parserTest
 602+ && ( ( preg_match( '/\\bdisabled\\b/i', $data['options'] ) && !$this->parserTest->runDisabled )
 603+ || !preg_match( "/" . $this->parserTest->regex . "/i", $data['test'] ) ) ) {
 604+ # disabled test
 605+ $data = array();
 606+ $section = null;
 607+
 608+ continue;
 609+ }
 610+
 611+ global $wgUseTeX;
 612+
 613+ if ( $this->parserTest &&
 614+ preg_match( '/\\bmath\\b/i', $data['options'] ) && !$wgUseTeX ) {
 615+ # don't run math tests if $wgUseTeX is set to false in LocalSettings
 616+ $data = array();
 617+ $section = null;
 618+
 619+ continue;
 620+ }
 621+
 622+ if ( $this->parserTest ) {
 623+ $this->test = array(
 624+ 'test' => ParserTest::chomp( $data['test'] ),
 625+ 'input' => ParserTest::chomp( $data['input'] ),
 626+ 'result' => ParserTest::chomp( $data['result'] ),
 627+ 'options' => ParserTest::chomp( $data['options'] ),
 628+ 'config' => ParserTest::chomp( $data['config'] ) );
 629+ } else {
 630+ $this->test['test'] = $data['test'];
 631+ }
 632+
 633+ return true;
 634+ }
 635+
 636+ if ( isset ( $data[$section] ) ) {
 637+ wfDie( "duplicate section '$section' at line {$this->lineNum} of $this->file\n" );
 638+ }
 639+
 640+ $data[$section] = '';
 641+
 642+ continue;
 643+ }
 644+
 645+ if ( $section ) {
 646+ $data[$section] .= $line;
 647+ }
 648+ }
 649+
 650+ return false;
 651+ }
 652+}
Property changes on: trunk/phase3/tests/testHelpers.inc
___________________________________________________________________
Added: svn:mergeinfo
1653 Merged /branches/phpunit-restructure/maintenance/tests/testHelpers.inc:r72257-72560
Added: svn:eol-style
2654 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r82969Followup to r82874, restore lost editsoverlordq21:57, 28 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73884Move parser test related stuff to tests directory...demon12:24, 28 September 2010
r78389Fix a few more paths, restore a few files lost in the movedemon16:48, 14 December 2010
r82873Remove testHelpers.{inc,php} for recommiting with history lost in r78389.platonides23:31, 26 February 2011

Comments

#Comment by OverlordQ (talk | contribs)   21:51, 28 February 2011

Breaks parserTests, is looking for commandLine in the wrong place

#Comment by 😂 (talk | contribs)   15:47, 27 March 2011

Was fixed in r82969

Status & tagging log