31require __DIR__ .
'/../../maintenance/Maintenance.php';
37 parent::__construct();
40 $this->
addOption(
'quick',
'Suppress diff output of failed tests' );
41 $this->
addOption(
'quiet',
'Suppress notification of passed tests (shows only failed tests)' );
42 $this->
addOption(
'show-output',
'Show expected and actual output' );
43 $this->
addOption(
'color',
'[=yes|no] Override terminal detection and force ' .
44 'color output on or off. Use wgCommandLineDarkBg = true; if your term is dark',
46 $this->
addOption(
'regex',
'Only run tests whose descriptions which match given regex',
48 $this->
addOption(
'filter',
'Alias for --regex',
false,
true );
49 $this->
addOption(
'file',
'Run test cases from a custom file instead of parserTests.txt',
50 false,
true,
false,
true );
51 $this->
addOption(
'record',
'Record tests in database' );
52 $this->
addOption(
'compare',
'Compare with recorded results, without updating the database.' );
53 $this->
addOption(
'setversion',
'When using --record, set the version string to use (useful' .
54 'with "git rev-parse HEAD" to get the exact revision)',
56 $this->
addOption(
'keep-uploads',
'Re-use the same upload directory for each ' .
57 'test, don\'t delete it' );
58 $this->
addOption(
'file-backend',
'Use the file backend with the given name,' .
59 'and upload files to it, instead of creating a mock file backend.',
false,
true );
60 $this->
addOption(
'upload-dir',
'Specify the upload directory to use. Useful in ' .
61 'conjunction with --keep-uploads. Causes a real (non-mock) file backend to ' .
62 'be used.',
false,
true );
63 $this->
addOption(
'run-disabled',
'run disabled tests' );
64 $this->
addOption(
'disable-save-parse',
'Don\'t run the parser when ' .
65 'inserting articles into the database' );
66 $this->
addOption(
'dwdiff',
'Use dwdiff to display diff output' );
67 $this->
addOption(
'mark-ws',
'Mark whitespace in diffs by replacing it with symbols' );
68 $this->
addOption(
'norm',
'Apply a comma-separated list of normalization functions to ' .
69 'both the expected and actual output in order to resolve ' .
70 'irrelevant differences. The accepted normalization functions ' .
71 'are: removeTbody to remove <tbody> tags; and trimWhitespace ' .
72 'to trim whitespace from the start and end of text nodes.',
75 'Use the wiki\'s Tidy configuration instead of known-good' .
92 $version = $db->getServerVersion();
94 die(
"Parser tests require SQLite version 3.6 or later, you have $version\n" );
100 echo
"This is MediaWiki version {$version}.\n\n";
118 $compare = $this->
hasOption(
'compare' );
121 if ( $regex !==
false ) {
122 $regex =
"/$regex/i";
125 echo
"Warning: --record cannot be used with --regex, disabling --record\n";
139 'showDiffs' => !$this->
hasOption(
'quick' ),
140 'showProgress' => !$this->
hasOption(
'quiet' ),
141 'showFailure' => !$this->
hasOption(
'quiet' )
142 || ( !$record && !$compare ),
143 'showOutput' => $this->
hasOption(
'show-output' ),
144 'useDwdiff' => $this->
hasOption(
'dwdiff' ),
145 'markWhitespace' => $this->
hasOption(
'mark-ws' ),
150 if ( $record || $compare ) {
151 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
152 $recorderLB = $lbFactory->newMainLB();
154 $recorderDB = $recorderLB->getConnection(
DB_MASTER );
163 function ( $name ) use ( $regex ) {
165 if ( $regex ===
false ) {
181 'keep-uploads' => $this->
hasOption(
'keep-uploads' ),
182 'run-disabled' => $this->
hasOption(
'run-disabled' ),
183 'disable-save-parse' => $this->
hasOption(
'disable-save-parse' ),
184 'use-tidy-config' => $this->
hasOption(
'use-tidy-config' ),
185 'file-backend' => $this->
getOption(
'file-backend' ),
186 'upload-dir' => $this->
getOption(
'upload-dir' ),
189 $ok = $tester->runTestsFromFiles( $files );
191 $recorderLB->closeAll();
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfIsWindows()
Check if the operating system is Windows.
Terminal that supports ANSI escape sequences.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
static requireTestsAutoloader()
Call this to set up the autoloader to allow classes to be used from the tests directory.
hasOption( $name)
Checks to see if a particular option exists.
static posix_isatty( $fd)
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but trea...
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
This is a TestRecorder representing a collection of other TestRecorders.
addRecorder(TestRecorder $recorder)
This is a TestRecorder responsible for printing information about progress, success and failure to th...
static getParserTestFiles()
Get list of filenames to extension and core parser tests.
__construct()
Default constructor.
execute()
Do the actual work.
finalSetup()
Handle some last-minute setup here.
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
static applyInitialConfig()
This should be called before Setup.php, e.g.
whereas SearchGetNearMatch runs after $term
require_once RUN_MAINTENANCE_IF_MAIN