3 * MediaWiki parser test suite
5 * Copyright © 2004 Brion Vibber <brion@pobox.com>
6 * https://www.mediawiki.org/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
27 $otions = array( 'quick', 'color', 'quiet', 'help', 'show-output',
28 'record', 'run-disabled', 'run-parsoid' );
29 $optionsWithArgs = array( 'regex', 'filter', 'seed', 'setversion' );
31 require_once __DIR__
. '/../maintenance/commandLine.inc';
32 require_once __DIR__
. '/TestsAutoLoader.php';
34 if ( isset( $options['help'] ) ) {
36 MediaWiki $wgVersion parser test suite
37 Usage: php parserTests.php [options...]
40 --quick Suppress diff output of failed tests
41 --quiet Suppress notification of passed tests (shows only failed tests)
42 --show-output Show expected and actual output
43 --color[=yes|no] Override terminal detection and force color output on or off
44 use wgCommandLineDarkBg = true; if your term is dark
45 --regex Only run tests whose descriptions which match given regex
46 --filter Alias for --regex
47 --file=<testfile> Run test cases from a custom file instead of parserTests.txt
48 --record Record tests in database
49 --compare Compare with recorded results, without updating the database.
50 --setversion When using --record, set the version string to use (useful
51 with git-svn so that you can get the exact revision)
52 --keep-uploads Re-use the same upload directory for each test, don't delete it
53 --fuzz Do a fuzz test instead of a normal test
54 --seed <n> Start the fuzz test from the specified seed
55 --help Show this help message
56 --run-disabled run disabled tests
57 --run-parsoid run parsoid tests (normally disabled)
63 # Cases of weird db corruption were encountered when running tests on earlyish
65 if ( $wgDBtype == 'sqlite' ) {
66 $db = wfGetDB( DB_MASTER
);
67 $version = $db->getServerVersion();
68 if ( version_compare( $version, '3.6' ) < 0 ) {
69 die( "Parser tests require SQLite version 3.6 or later, you have $version\n" );
73 $tester = new ParserTest( $options );
75 if ( isset( $options['file'] ) ) {
76 $files = array( $options['file'] );
78 // Default parser tests and any set from extensions or local config
79 $files = $wgParserTestFiles;
82 # Print out software version to assist with locating regressions
83 $version = SpecialVersion
::getVersion();
84 echo "This is MediaWiki version {$version}.\n\n";
86 if ( isset( $options['fuzz'] ) ) {
87 $tester->fuzzTest( $files );
89 $ok = $tester->runTestsFromFiles( $files );