00001 <?php 00002 # Copyright (C) 2004 Brion Vibber <brion@pobox.com> 00003 # http://www.mediawiki.org/ 00004 # 00005 # This program is free software; you can redistribute it and/or modify 00006 # it under the terms of the GNU General Public License as published by 00007 # the Free Software Foundation; either version 2 of the License, or 00008 # (at your option) any later version. 00009 # 00010 # This program is distributed in the hope that it will be useful, 00011 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 # GNU General Public License for more details. 00014 # 00015 # You should have received a copy of the GNU General Public License along 00016 # with this program; if not, write to the Free Software Foundation, Inc., 00017 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 # http://www.gnu.org/copyleft/gpl.html 00019 00026 require('parserTests.inc'); 00027 00028 if( isset( $options['help'] ) ) { 00029 echo <<<ENDS 00030 MediaWiki $wgVersion parser test suite 00031 Usage: php parserTests.php [options...] 00032 00033 Options: 00034 --quick Suppress diff output of failed tests 00035 --quiet Suppress notification of passed tests (shows only failed tests) 00036 --show-output Show expected and actual output 00037 --color[=yes|no] Override terminal detection and force color output on or off 00038 use wgCommandLineDarkBg = true; if your term is dark 00039 --regex Only run tests whose descriptions which match given regex 00040 --file=<testfile> Run test cases from a custom file instead of parserTests.txt 00041 --record Record tests in database 00042 --compare Compare with recorded results, without updating the database. 00043 --setversion When using --record, set the version string to use (useful 00044 with git-svn so that you can get the exact revision) 00045 --keep-uploads Re-use the same upload directory for each test, don't delete it 00046 --fuzz Do a fuzz test instead of a normal test 00047 --seed <n> Start the fuzz test from the specified seed 00048 --help Show this help message 00049 --run-disabled run disabled tests 00050 --upload Upload test results to remote wiki (per \$wgParserTestRemote) 00051 00052 ENDS; 00053 exit( 0 ); 00054 } 00055 00056 # Cases of weird db corruption were encountered when running tests on earlyish 00057 # versions of SQLite 00058 if ( $wgDBtype == 'sqlite' ) { 00059 $db = wfGetDB( DB_MASTER ); 00060 $version = $db->getServerVersion(); 00061 if ( version_compare( $version, '3.6' ) < 0 ) { 00062 die( "Parser tests require SQLite version 3.6 or later, you have $version\n" ); 00063 } 00064 } 00065 00066 # There is a convention that the parser should never 00067 # refer to $wgTitle directly, but instead use the title 00068 # passed to it. 00069 $wgTitle = Title::newFromText( 'Parser test script do not use' ); 00070 $tester = new ParserTest(); 00071 00072 if( isset( $options['file'] ) ) { 00073 $files = array( $options['file'] ); 00074 } else { 00075 // Default parser tests and any set from extensions or local config 00076 $files = $wgParserTestFiles; 00077 } 00078 00079 # Print out software version to assist with locating regressions 00080 $version = SpecialVersion::getVersion(); 00081 echo( "This is MediaWiki version {$version}.\n\n" ); 00082 00083 if ( isset( $options['fuzz'] ) ) { 00084 $tester->fuzzTest( $files ); 00085 } else { 00086 $ok = $tester->runTestsFromFiles( $files ); 00087 exit ($ok ? 0 : 1); 00088 }