Non-word characters don't terminate tag names.
[mediawiki.git] / tests / parserTests.php
blobdebb35751b21759f4669f44653b0be5d911faf6d
1 <?php
2 /**
3 * MediaWiki parser test suite
5 * Copyright © 2004 Brion Vibber <brion@pobox.com>
6 * http://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
23 * @file
24 * @ingroup Testing
27 $otions = array( 'quick', 'color', 'quiet', 'help', 'show-output', 'record', 'run-disabled', 'run-parsoid' );
28 $optionsWithArgs = array( 'regex', 'filter', 'seed', 'setversion' );
30 require_once __DIR__ . '/../maintenance/commandLine.inc';
31 require_once __DIR__ . '/TestsAutoLoader.php';
33 if ( isset( $options['help'] ) ) {
34 echo <<<ENDS
35 MediaWiki $wgVersion parser test suite
36 Usage: php parserTests.php [options...]
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 --filter Alias for --regex
46 --file=<testfile> Run test cases from a custom file instead of parserTests.txt
47 --record Record tests in database
48 --compare Compare with recorded results, without updating the database.
49 --setversion When using --record, set the version string to use (useful
50 with git-svn so that you can get the exact revision)
51 --keep-uploads Re-use the same upload directory for each test, don't delete it
52 --fuzz Do a fuzz test instead of a normal test
53 --seed <n> Start the fuzz test from the specified seed
54 --help Show this help message
55 --run-disabled run disabled tests
56 --run-parsoid run parsoid tests (normally disabled)
58 ENDS;
59 exit( 0 );
62 # Cases of weird db corruption were encountered when running tests on earlyish
63 # versions of SQLite
64 if ( $wgDBtype == 'sqlite' ) {
65 $db = wfGetDB( DB_MASTER );
66 $version = $db->getServerVersion();
67 if ( version_compare( $version, '3.6' ) < 0 ) {
68 die( "Parser tests require SQLite version 3.6 or later, you have $version\n" );
72 # There is a convention that the parser should never
73 # refer to $wgTitle directly, but instead use the title
74 # passed to it.
75 $wgTitle = Title::newFromText( 'Parser test script do not use' );
76 $tester = new ParserTest( $options );
78 if ( isset( $options['file'] ) ) {
79 $files = array( $options['file'] );
80 } else {
81 // Default parser tests and any set from extensions or local config
82 $files = $wgParserTestFiles;
85 # Print out software version to assist with locating regressions
86 $version = SpecialVersion::getVersion();
87 echo "This is MediaWiki version {$version}.\n\n";
89 if ( isset( $options['fuzz'] ) ) {
90 $tester->fuzzTest( $files );
91 } else {
92 $ok = $tester->runTestsFromFiles( $files );
93 exit( $ok ? 0 : 1 );