MediaWiki  REL1_24
parserTests.php
Go to the documentation of this file.
00001 <?php
00027 $otions = array( 'quick', 'color', 'quiet', 'help', 'show-output',
00028     'record', 'run-disabled', 'run-parsoid' );
00029 $optionsWithArgs = array( 'regex', 'filter', 'seed', 'setversion' );
00030 
00031 require_once __DIR__ . '/../maintenance/commandLine.inc';
00032 require_once __DIR__ . '/TestsAutoLoader.php';
00033 
00034 if ( isset( $options['help'] ) ) {
00035     echo <<<ENDS
00036 MediaWiki $wgVersion parser test suite
00037 Usage: php parserTests.php [options...]
00038 
00039 Options:
00040   --quick          Suppress diff output of failed tests
00041   --quiet          Suppress notification of passed tests (shows only failed tests)
00042   --show-output    Show expected and actual output
00043   --color[=yes|no] Override terminal detection and force color output on or off
00044                    use wgCommandLineDarkBg = true; if your term is dark
00045   --regex          Only run tests whose descriptions which match given regex
00046   --filter         Alias for --regex
00047   --file=<testfile> Run test cases from a custom file instead of parserTests.txt
00048   --record         Record tests in database
00049   --compare        Compare with recorded results, without updating the database.
00050   --setversion     When using --record, set the version string to use (useful
00051                    with git-svn so that you can get the exact revision)
00052   --keep-uploads   Re-use the same upload directory for each test, don't delete it
00053   --fuzz           Do a fuzz test instead of a normal test
00054   --seed <n>       Start the fuzz test from the specified seed
00055   --help           Show this help message
00056   --run-disabled   run disabled tests
00057   --run-parsoid    run parsoid tests (normally disabled)
00058 
00059 ENDS;
00060     exit( 0 );
00061 }
00062 
00063 # Cases of weird db corruption were encountered when running tests on earlyish
00064 # versions of SQLite
00065 if ( $wgDBtype == 'sqlite' ) {
00066     $db = wfGetDB( DB_MASTER );
00067     $version = $db->getServerVersion();
00068     if ( version_compare( $version, '3.6' ) < 0 ) {
00069         die( "Parser tests require SQLite version 3.6 or later, you have $version\n" );
00070     }
00071 }
00072 
00073 # There is a convention that the parser should never
00074 # refer to $wgTitle directly, but instead use the title
00075 # passed to it.
00076 $wgTitle = Title::newFromText( 'Parser test script do not use' );
00077 $tester = new ParserTest( $options );
00078 
00079 if ( isset( $options['file'] ) ) {
00080     $files = array( $options['file'] );
00081 } else {
00082     // Default parser tests and any set from extensions or local config
00083     $files = $wgParserTestFiles;
00084 }
00085 
00086 # Print out software version to assist with locating regressions
00087 $version = SpecialVersion::getVersion();
00088 echo "This is MediaWiki version {$version}.\n\n";
00089 
00090 if ( isset( $options['fuzz'] ) ) {
00091     $tester->fuzzTest( $files );
00092 } else {
00093     $ok = $tester->runTestsFromFiles( $files );
00094     exit( $ok ? 0 : 1 );
00095 }