42 public function start();
60 public function end();
80 $this->success += (
$result ? 1 : 0 );
88 if ( $this->total > 0 ) {
97 print $this->
term->color( 1 ) .
"Passed $success of $total tests ($ratio)... ";
100 print $this->
term->color( 32 ) .
"ALL TESTS PASSED!";
103 print $this->
term->color( 31 ) .
"$failed tests failed!";
124 parent::__construct(
$parent );
128 $this->db = $this->lb->getConnection(
DB_MASTER );
138 if ( !$this->db->tableExists(
'testrun', __METHOD__ )
139 || !$this->db->tableExists(
'testitem', __METHOD__ )
141 print "WARNING> `testrun` table not found in database.\n";
142 $this->prevRun =
false;
145 $this->prevRun = $this->db->selectField(
'testrun',
'MAX(tr_id)' );
153 return "$test subtest #$subtest";
160 parent::record( $test, $subtest,
$result );
165 if ( $this->prevRun ) {
169 'fp' =>
'previously failing test(s) now PASSING! :)',
170 'pn' =>
'previously PASSING test(s) removed o_O',
171 'np' =>
'new PASSING test(s) :)',
173 'pf' =>
'previously passing test(s) now FAILING! :(',
174 'fn' =>
'previously FAILING test(s) removed O_o',
175 'nf' =>
'new FAILING test(s) :(',
176 'ff' =>
'still FAILING test(s) :(',
181 $res = $this->db->select(
'testitem', [
'ti_name',
'ti_success' ],
182 [
'ti_run' => $this->prevRun ], __METHOD__ );
184 foreach (
$res as $row ) {
185 if ( !$this->parent->regex
186 || preg_match(
"/{$this->parent->regex}/i", $row->ti_name )
188 $prevResults[$row->ti_name] = $row->ti_success;
192 $combined = array_keys( $this->results + $prevResults );
194 # Determine breakdown by change type
196 foreach ( $combined
as $test ) {
197 if ( !isset( $prevResults[$test] ) ) {
199 } elseif ( $prevResults[$test] == 1 ) {
205 if ( !isset( $this->results[$test] ) ) {
207 } elseif ( $this->results[$test] == 1 ) {
213 $code = $before . $after;
215 if ( isset( $table[
$code] ) ) {
221 foreach ( $table
as $code => $label ) {
222 if ( !empty( $breakdown[
$code] ) ) {
223 $count = count( $breakdown[$code] );
224 printf(
"\n%4d %s\n",
$count, $label );
226 foreach ( $breakdown[$code]
as $differing_test_name => $statusInfo ) {
227 print " * $differing_test_name [$statusInfo]\n";
232 print "No previous test runs to compare against.\n";
249 if ( $after ==
'n' ) {
250 $changedRun = $this->db->selectField(
'testitem',
252 [
'ti_name' => $testname ],
254 $appear = $this->db->selectRow(
'testrun',
255 [
'tr_date',
'tr_mw_version' ],
256 [
'tr_id' => $changedRun ],
259 return "First recorded appearance: "
260 . date(
"d-M-Y H:i:s", strtotime( $appear->tr_date ) )
261 .
", " . $appear->tr_mw_version;
267 'ti_name' => $testname,
268 'ti_success' => ( $after ==
'f' ?
"1" :
"0" ) ];
270 if ( $this->curRun ) {
271 $conds[] =
"ti_run != " . $this->db->addQuotes( $this->curRun );
274 $changedRun = $this->db->selectField(
'testitem',
'MAX(ti_run)', $conds, __METHOD__ );
277 if ( is_null( $changedRun ) ) {
278 if ( $after ==
"f" ) {
279 return "Has never passed";
281 return "Has never failed";
288 $pre = $this->db->selectRow(
'testrun',
289 [
'tr_date',
'tr_mw_version' ],
290 [
'tr_id' => $changedRun ],
292 $post = $this->db->selectRow(
'testrun',
293 [
'tr_date',
'tr_mw_version' ],
294 [
"tr_id > " . $this->db->addQuotes( $changedRun ) ],
296 [
"LIMIT" => 1,
"ORDER BY" =>
'tr_id' ]
300 $postDate = date(
"d-M-Y H:i:s", strtotime( $post->tr_date ) ) .
", {$post->tr_mw_version}";
305 return ( $after ==
"f" ?
"Introduced" :
"Fixed" ) .
" between "
306 . date(
"d-M-Y H:i:s", strtotime(
$pre->tr_date ) ) .
", " .
$pre->tr_mw_version
314 $this->lb->closeAll();
327 $this->db->begin( __METHOD__ );
329 if ( !$this->db->tableExists(
'testrun' )
330 || !$this->db->tableExists(
'testitem' )
332 print "WARNING> `testrun` table not found in database. Trying to create table.\n";
333 $this->db->sourceFile( $this->db->patchPath(
'patch-testrun.sql' ) );
334 echo
"OK, resuming.\n";
339 $this->db->insert(
'testrun',
341 'tr_date' => $this->db->timestamp(),
343 'tr_php_version' => PHP_VERSION,
344 'tr_db_version' => $this->db->getServerVersion(),
345 'tr_uname' => php_uname()
348 if ( $this->db->getType() ===
'postgres' ) {
349 $this->curRun = $this->db->currentSequenceValue(
'testrun_id_seq' );
351 $this->curRun = $this->db->insertId();
362 parent::record( $test, $subtest,
$result );
364 $this->db->insert(
'testitem',
366 'ti_run' => $this->curRun,
367 'ti_name' => $this->
getName( $test, $subtest ),
368 'ti_success' =>
$result ? 1 : 0,
377 $this->db->commit( __METHOD__ );
397 # Create a fake parser tests which never run anything unless
398 # asked to do so. This will avoid running hooks for a disabled test
404 $this->fh = fopen( $this->
file,
"rt" );
407 throw new MWException(
"Couldn't open file '$file'\n" );
413 $this->lineNum = $this->index = 0;
417 if ( fseek( $this->fh, 0 ) ) {
418 throw new MWException(
"Couldn't fseek to the start of '$this->file'\n" );
447 return $this->eof !=
true;
453 $input = $this->
checkSection( [
'wikitext',
'input' ],
false );
456 $tidy = $this->
checkSection( [
'html/php+tidy',
'html+tidy' ],
false );
457 if ( $tidy !=
false ) {
458 if ( $this->nextSubTest == 0 ) {
460 $this->nextSubTest = 1;
464 $this->nextSubTest = 0;
469 if ( !isset( $this->sectionData[
'options'] ) ) {
470 $this->sectionData[
'options'] =
'';
473 if ( !isset( $this->sectionData[
'config'] ) ) {
474 $this->sectionData[
'config'] =
'';
477 $isDisabled = preg_match(
'/\\bdisabled\\b/i', $this->sectionData[
'options'] ) &&
478 !$this->parserTest->runDisabled;
479 $isParsoidOnly = preg_match(
'/\\bparsoid\\b/i', $this->sectionData[
'options'] ) &&
481 !$this->parserTest->runParsoid;
482 $isFiltered = !preg_match(
"/" . $this->parserTest->regex .
"/i", $this->sectionData[
'test'] );
483 if ( $input ==
false ||
$result ==
false || $isDisabled || $isParsoidOnly || $isFiltered ) {
488 # We are really going to run the test, run pending hooks and hooks function
489 wfDebug( __METHOD__ .
" unleashing delayed test for: {$this->sectionData['test']}" );
490 $hooksResult = $this->delayedParserTest->unleash( $this->parserTest );
491 if ( !$hooksResult ) {
492 # Some hook reported an issue. Abort.
493 throw new MWException(
"Problem running requested parser hook from the test file" );
504 if ( $tidy !=
false ) {
505 $this->test[
'options'] .=
" tidy";
511 # Run additional subtests of previous test
512 while ( $this->nextSubTest > 0 ) {
519 # Reset hooks for the delayed test object
520 $this->delayedParserTest->reset();
522 while (
false !== (
$line = fgets( $this->fh ) ) ) {
527 $this->section = strtolower(
$matches[1] );
529 if ( $this->section ==
'endarticle' ) {
533 $this->parserTest->addArticle(
535 $this->sectionData[
'text'], $this->lineNum );
542 if ( $this->section ==
'endhooks' ) {
545 foreach ( explode(
"\n", $this->sectionData[
'hooks'] )
as $line ) {
546 $line = trim( $line );
549 $this->delayedParserTest->requireHook( $line );
558 if ( $this->section ==
'endfunctionhooks' ) {
561 foreach ( explode(
"\n", $this->sectionData[
'functionhooks'] )
as $line ) {
562 $line = trim( $line );
565 $this->delayedParserTest->requireFunctionHook( $line );
574 if ( $this->section ==
'endtransparenthooks' ) {
577 foreach ( explode(
"\n", $this->sectionData[
'transparenthooks'] )
as $line ) {
578 $line = trim( $line );
581 $this->delayedParserTest->requireTransparentHook( $line );
590 if ( $this->section ==
'end' ) {
596 }
while ( $this->nextSubTest > 0 );
597 # go on to next test (since this was disabled)
599 $this->delayedParserTest->reset();
603 if ( isset( $this->sectionData[$this->section] ) ) {
604 throw new MWException(
"duplicate section '$this->section' "
605 .
"at line {$this->lineNum} of $this->file\n" );
613 if ( $this->section ) {
625 $this->sectionData = [];
626 $this->section = null;
644 if ( is_null( $this->section ) ) {
645 throw new MWException( __METHOD__ .
" can not verify a null section!\n" );
651 throw new MWException( __METHOD__ .
" can not verify zero sections!\n" );
656 return isset( $data[$token] );
664 "'%s' without '%s' at line %s of %s\n",
673 "'%s' with unexpected tokens '%s' at line %s of %s\n",
681 return array_values(
$tokens )[0];
691 $test = parent::current();
727 $this->transparentHooks = [];
739 throw new MWException( __METHOD__ .
" must be passed an instance of ParserTest or "
740 .
"NewParserTest classes\n" );
743 # Trigger delayed hooks. Any failure will make us abort
744 foreach ( $this->
hooks as $hook ) {
745 $ret = $parserTest->requireHook( $hook );
751 # Trigger delayed function hooks. Any failure will make us abort
752 foreach ( $this->fnHooks
as $fnHook ) {
753 $ret = $parserTest->requireFunctionHook( $fnHook );
759 # Trigger delayed transparent hooks. Any failure will make us abort
760 foreach ( $this->transparentHooks
as $hook ) {
761 $ret = $parserTest->requireTransparentHook( $hook );
767 # Delayed execution was successful.
777 $this->
hooks[] = $hook;
786 $this->fnHooks[] = $fnHook;
795 $this->transparentHooks[] = $hook;
811 $wgDjvuRenderer = $wgDjvuRenderer ? $wgDjvuRenderer :
'/usr/bin/ddjvu';
812 $wgDjvuDump = $wgDjvuDump ? $wgDjvuDump :
'/usr/bin/djvudump';
813 $wgDjvuToXML = $wgDjvuToXML ? $wgDjvuToXML :
'/usr/bin/djvutoxml';
814 $wgDjvuTxt = $wgDjvuTxt ? $wgDjvuTxt :
'/usr/bin/djvutxt';
816 if ( !in_array(
'djvu', $wgFileExtensions ) ) {
817 $wgFileExtensions[] =
'djvu';
829 return is_executable( $wgDjvuRenderer )
830 && is_executable( $wgDjvuDump )
831 && is_executable( $wgDjvuToXML )
832 && is_executable( $wgDjvuTxt );
849 $this->internalTidy = extension_loaded(
'tidy' ) &&
850 class_exists(
'tidy' ) && !
wfIsHHVM();
852 $this->externalTidy = is_executable( $wgTidyBin ) ||
isInternal()
Returns true if we should use internal tidy.
record($test, $subtest, $result)
Called after each test.
record($test, $subtest, $result)
Called after each test.
wfPercent($nr, $acc=2, $round=true)
requireFunctionHook($fnHook)
Similar to ParserTest object but does not run anything Use unleash() to really execute the hook funct...
wfIsHHVM()
Check if we are running under HHVM.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
$sectionData
String|null: current test section being analyzed.
$wgDjvuTxt
Path of the djvutxt DJVU text extraction utility Enable this and $wgDjvuDump to enable text layer ext...
__construct($file, $parserTest)
static locateExecutableInDefaultPaths($names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
when a variable name is used in a it is silently declared as a new local masking the global
static chomp($s)
Remove last character if it is a newline utility.
which are not or by specifying more than one search term(only pages containing all of the search terms will appear in the result).</td >< td >
__construct()
Initialises DjVu tools global with default values.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
checkSection($tokens, $fatal=true)
Verify the current section data has some value for the given token name(s) (first parameter)...
__construct($parent)
This should be called before the table prefix is changed.
record($test, $subtest, $result)
Record an individual test item's success or failure to the db.
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
__construct()
Determine if there is a usable tidy.
reportPercentage($success, $total)
Although marked as a stub, can work independently.
$wgDjvuRenderer
Path of the ddjvu DJVU renderer Enable this and $wgDjvuDump to enable djvu rendering example: $wgDjvu...
report()
Called before finishing the test run.
start()
Set up result recording; insert a record for the run with the date and all that fun stuff...
reset()
Init/reset or forgot about the current delayed test.
A class to delay execution of a parser test hooks.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
start()
Called at beginning of the parser test run.
unleash(&$parserTest)
Called whenever we actually want to run the hook.
Initialize and detect the DjVu files support.
clearSection()
Clear section name and its data.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
An iterator for use as a phpunit data provider.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
end()
Called at the end of the parser test run.
Initialize and detect the tidy support.
requireTransparentHook($hook)
Similar to ParserTest object but does not run anything Use unleash() to really execute the hook funct...
$wgFileExtensions
This is the list of preferred extensions for uploading files.
end()
Called at the end of the parser test run.
$wgDjvuDump
Path of the djvudump executable Enable this and $wgDjvuRenderer to enable djvu rendering example: $wg...
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
report()
Called before finishing the test run.
wfGetLBFactory()
Get the load balancer factory object.
Interface to record parser test results.
end()
Commit transaction and clean up for result recording.
report()
Called before finishing the test run.
getTestStatusInfo($testname, $after)
Returns a string giving information about when a test last had a status change.
isEnabled()
Returns true if the DjVu tools are usable.
$wgDjvuToXML
Path of the djvutoxml executable This works like djvudump except much, much slower as of version 3...
ParserTest MediaWikiParserTest $parserTest
An instance of ParserTest (parserTests.php) or MediaWikiParserTest (phpunit)
$hooks
Initialized on construction.
end()
Close the DB connection.
requireHook($hook)
Similar to ParserTest object but does not run anything Use unleash() to really execute the hook...
start()
Called at beginning of the parser test run.
record($test, $subtest, $result)
Called after each test.
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped $pre
isEnabled()
Returns true if tidy is usable.
start()
Set up result recording; insert a record for the run with the date and all that fun stuff...