Go to the documentation of this file.
29 define(
'MW_PARSER_TEST',
true );
31 require __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(
'run-parsoid',
'run parsoid tests (normally disabled)' );
65 $this->
addOption(
'disable-save-parse',
'Don\'t run the parser when ' .
66 'inserting articles into the database' );
67 $this->
addOption(
'dwdiff',
'Use dwdiff to display diff output' );
68 $this->
addOption(
'mark-ws',
'Mark whitespace in diffs by replacing it with symbols' );
69 $this->
addOption(
'norm',
'Apply a comma-separated list of normalization functions to ' .
70 'both the expected and actual output in order to resolve ' .
71 'irrelevant differences. The accepted normalization functions ' .
72 'are: removeTbody to remove <tbody> tags; and trimWhitespace ' .
73 'to trim whitespace from the start and end of text nodes.',
76 'Use the wiki\'s Tidy configuration instead of known-good' .
93 $version = $db->getServerVersion();
94 if ( version_compare( $version,
'3.6' ) < 0 ) {
95 die(
"Parser tests require SQLite version 3.6 or later, you have $version\n" );
101 echo
"This is MediaWiki version {$version}.\n\n";
119 $compare = $this->
hasOption(
'compare' );
122 if ( $regex !==
false ) {
123 $regex =
"/$regex/i";
126 echo
"Warning: --record cannot be used with --regex, disabling --record\n";
140 'showDiffs' => !$this->
hasOption(
'quick' ),
141 'showProgress' => !$this->
hasOption(
'quiet' ),
142 'showFailure' => !$this->
hasOption(
'quiet' )
143 || ( !$record && !$compare ),
144 'showOutput' => $this->
hasOption(
'show-output' ),
145 'useDwdiff' => $this->
hasOption(
'dwdiff' ),
146 'markWhitespace' => $this->
hasOption(
'mark-ws' ),
151 if ( $record || $compare ) {
152 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
153 $recorderLB = $lbFactory->newMainLB();
155 $recorderDB = $recorderLB->getConnection(
DB_MASTER );
166 if ( $regex ===
false ) {
169 return (
bool)preg_match( $regex,
$name );
175 $files = $this->
getOption(
'file', ParserTestRunner::getParserTestFiles() );
179 $tester =
new ParserTestRunner( $recorder, [
182 'keep-uploads' => $this->
hasOption(
'keep-uploads' ),
183 'run-disabled' => $this->
hasOption(
'run-disabled' ),
184 'run-parsoid' => $this->
hasOption(
'run-parsoid' ),
185 'disable-save-parse' => $this->
hasOption(
'disable-save-parse' ),
186 'use-tidy-config' => $this->
hasOption(
'use-tidy-config' ),
187 'file-backend' => $this->
getOption(
'file-backend' ),
188 'upload-dir' => $this->
getOption(
'upload-dir' ),
191 $ok = $tester->runTestsFromFiles( $files );
193 $recorderLB->closeAll();
This is a TestRecorder responsible for printing information about progress, success and failure to th...
For QUnit the mediawiki tests qunit testrunner dependency will be added to any module whereas SearchGetNearMatch runs after $term
__construct()
Default constructor.
execute()
Do the actual work.
addDescription( $text)
Set the description text.
require_once RUN_MAINTENANCE_IF_MAIN
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
static applyInitialConfig()
This should be called before Setup.php, e.g.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Terminal that supports ANSI escape sequences.
Allows to change the fields on the form that will be generated $name
static getVersion( $flags='', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
wfIsWindows()
Check if the operating system is Windows.
static requireTestsAutoloader()
Call this to set up the autoloader to allow classes to be used from the tests directory.
static posix_isatty( $fd)
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but trea...
getOption( $name, $default=null)
Get an option, or return the default.
finalSetup()
Handle some last-minute setup here.
addRecorder(TestRecorder $recorder)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
hasOption( $name)
Checks to see if a particular option exists.
This is a TestRecorder representing a collection of other TestRecorders.