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