Don't look for pipes in the root node.
[lhc/web/wiklou.git] / tests / parserTests.php
1 <?php
2 /**
3 * MediaWiki parser test suite
4 *
5 * Copyright © 2004 Brion Vibber <brion@pobox.com>
6 * http://www.mediawiki.org/
7 *
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.
12 *
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.
17 *
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
22 *
23 * @file
24 * @ingroup Testing
25 */
26
27 $options = array( 'quick', 'color', 'quiet', 'help', 'show-output', 'record', 'run-disabled' );
28 $optionsWithArgs = array( 'regex', 'seed', 'setversion' );
29
30 require_once( dirname( __FILE__ ) . '/../maintenance/commandLine.inc' );
31
32 if ( isset( $options['help'] ) ) {
33 echo <<<ENDS
34 MediaWiki $wgVersion parser test suite
35 Usage: php parserTests.php [options...]
36
37 Options:
38 --quick Suppress diff output of failed tests
39 --quiet Suppress notification of passed tests (shows only failed tests)
40 --show-output Show expected and actual output
41 --color[=yes|no] Override terminal detection and force color output on or off
42 use wgCommandLineDarkBg = true; if your term is dark
43 --regex Only run tests whose descriptions which match given regex
44 --file=<testfile> Run test cases from a custom file instead of parserTests.txt
45 --record Record tests in database
46 --compare Compare with recorded results, without updating the database.
47 --setversion When using --record, set the version string to use (useful
48 with git-svn so that you can get the exact revision)
49 --keep-uploads Re-use the same upload directory for each test, don't delete it
50 --fuzz Do a fuzz test instead of a normal test
51 --seed <n> Start the fuzz test from the specified seed
52 --help Show this help message
53 --run-disabled run disabled tests
54 --upload Upload test results to remote wiki (per \$wgParserTestRemote)
55
56 ENDS;
57 exit( 0 );
58 }
59
60 # Cases of weird db corruption were encountered when running tests on earlyish
61 # versions of SQLite
62 if ( $wgDBtype == 'sqlite' ) {
63 $db = wfGetDB( DB_MASTER );
64 $version = $db->getServerVersion();
65 if ( version_compare( $version, '3.6' ) < 0 ) {
66 die( "Parser tests require SQLite version 3.6 or later, you have $version\n" );
67 }
68 }
69
70 # There is a convention that the parser should never
71 # refer to $wgTitle directly, but instead use the title
72 # passed to it.
73 $wgTitle = Title::newFromText( 'Parser test script do not use' );
74 $tester = new ParserTest($options);
75
76 if ( isset( $options['file'] ) ) {
77 $files = array( $options['file'] );
78 } else {
79 // Default parser tests and any set from extensions or local config
80 $files = $wgParserTestFiles;
81 }
82
83 # Print out software version to assist with locating regressions
84 $version = SpecialVersion::getVersion();
85 echo( "This is MediaWiki version {$version}.\n\n" );
86
87 if ( isset( $options['fuzz'] ) ) {
88 $tester->fuzzTest( $files );
89 } else {
90 $ok = $tester->runTestsFromFiles( $files );
91 exit ( $ok ? 0 : 1 );
92 }