2007-11-20 11:07:22 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2010-12-16 19:15:12 +00:00
|
|
|
* Performs fuzz-style testing of MediaWiki's preprocessor.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2007-11-20 11:07:22 +00:00
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
Deprecate Parser implementation methods (will be private in next release)
The following public methods were renamed and made private; the old name
is hard-deprecated and calls the new renamed private method:
Parser::doMagicLinks() => handleMagicLinks()
Parser::doDoubleUnderscore() => handleMagicLinks()
Parser::doHeadings() => handleHeadings()
Parser::doAllQuotes() => handleAllQuotes()
Parser::replaceExternalLinks() => handleExternalLinks()
Parser::replaceInternalLinks() => handleInternalLinks()
Parser::replaceInternalLinks2() => handleInternalLinks2()
Parser::getVariableValue() => expandMagicVariable()
Parser::initialiseVariables() => initializeVariables()
Parser::formatHeadings() => finalizeHeadings()
Parser::test{Pst,Preprocess,Srvus}() => fuzzTest{Pst,Preprocess,Srvus}()
Additionally, the following methods are not used externally, but are
used outside the Parser class by core code. They have been marked
@internal:
Parser::doQuotes() (used by {{#displaytitle}}),
Parser::getExternalLink{Rel,Attribs}() (used by Linker),
Parser::normalizeLinkUrl() (used by Special:LinkSearch and elsewhere).
Parser::{brace,arg,extension}Substitution() (used by PPFrame)
Code search query:
https://codesearch.wmflabs.org/deployed/?q=do%28MagicLinks%7CDoubleUnderscore%7CHeadings%7CAllQuotes%29%7Creplace%28ExternalLinks%7CInternalLinks%28%7C2%29%29%7CgetVariableValue%7CinitialiseVariables%7CformatHeadings%7Ctest%28Pst%7CPreprocess%7CSrvus%29%7CdoQuotes%7CgetExternalLink%28Rel%7CAttribs%29%7CnormalizeLinkUrl%7C%28brace%2Carg%2Cextension%29Substitution&i=nope&files=&repos=
Bug: T236810
Change-Id: I19a43ffc5dcfdd2981b51079c33422c964acb076
2019-10-28 19:52:50 +00:00
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
|
|
2016-02-04 00:04:12 +00:00
|
|
|
$optionsWithoutArgs = [ 'verbose' ];
|
2020-09-23 10:52:01 +00:00
|
|
|
require_once __DIR__ . '/CommandLineInc.php';
|
2007-11-20 11:07:22 +00:00
|
|
|
|
|
|
|
|
class PPFuzzTester {
|
2016-02-17 09:09:32 +00:00
|
|
|
public $hairs = [
|
2010-05-22 16:50:39 +00:00
|
|
|
'[[', ']]', '{{', '{{', '}}', '}}', '{{{', '}}}',
|
2007-11-20 11:07:22 +00:00
|
|
|
'<', '>', '<nowiki', '<gallery', '</nowiki>', '</gallery>', '<nOwIkI>', '</NoWiKi>',
|
2013-04-18 18:48:44 +00:00
|
|
|
'<!--', '-->',
|
2007-11-20 11:07:22 +00:00
|
|
|
"\n==", "==\n",
|
|
|
|
|
'|', '=', "\n", ' ', "\t", "\x7f",
|
2008-01-21 16:36:08 +00:00
|
|
|
'~~', '~~~', '~~~~', 'subst:',
|
2010-05-22 16:50:39 +00:00
|
|
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
2007-11-20 11:07:22 +00:00
|
|
|
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
2008-01-21 16:36:08 +00:00
|
|
|
|
|
|
|
|
// extensions
|
2010-05-22 16:50:39 +00:00
|
|
|
// '<ref>', '</ref>', '<references/>',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-09-14 18:57:14 +00:00
|
|
|
public $minLength = 0;
|
|
|
|
|
public $maxLength = 20;
|
|
|
|
|
public $maxTemplates = 5;
|
2016-09-27 03:15:08 +00:00
|
|
|
// public $outputTypes = [ 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ];
|
Deprecate Parser implementation methods (will be private in next release)
The following public methods were renamed and made private; the old name
is hard-deprecated and calls the new renamed private method:
Parser::doMagicLinks() => handleMagicLinks()
Parser::doDoubleUnderscore() => handleMagicLinks()
Parser::doHeadings() => handleHeadings()
Parser::doAllQuotes() => handleAllQuotes()
Parser::replaceExternalLinks() => handleExternalLinks()
Parser::replaceInternalLinks() => handleInternalLinks()
Parser::replaceInternalLinks2() => handleInternalLinks2()
Parser::getVariableValue() => expandMagicVariable()
Parser::initialiseVariables() => initializeVariables()
Parser::formatHeadings() => finalizeHeadings()
Parser::test{Pst,Preprocess,Srvus}() => fuzzTest{Pst,Preprocess,Srvus}()
Additionally, the following methods are not used externally, but are
used outside the Parser class by core code. They have been marked
@internal:
Parser::doQuotes() (used by {{#displaytitle}}),
Parser::getExternalLink{Rel,Attribs}() (used by Linker),
Parser::normalizeLinkUrl() (used by Special:LinkSearch and elsewhere).
Parser::{brace,arg,extension}Substitution() (used by PPFrame)
Code search query:
https://codesearch.wmflabs.org/deployed/?q=do%28MagicLinks%7CDoubleUnderscore%7CHeadings%7CAllQuotes%29%7Creplace%28ExternalLinks%7CInternalLinks%28%7C2%29%29%7CgetVariableValue%7CinitialiseVariables%7CformatHeadings%7Ctest%28Pst%7CPreprocess%7CSrvus%29%7CdoQuotes%7CgetExternalLink%28Rel%7CAttribs%29%7CnormalizeLinkUrl%7C%28brace%2Carg%2Cextension%29Substitution&i=nope&files=&repos=
Bug: T236810
Change-Id: I19a43ffc5dcfdd2981b51079c33422c964acb076
2019-10-28 19:52:50 +00:00
|
|
|
public $entryPoints = [ 'fuzzTestSrvus', 'fuzzTestPst', 'fuzzTestPreprocess' ];
|
2012-09-14 18:57:14 +00:00
|
|
|
public $verbose = false;
|
2014-04-22 21:07:08 +00:00
|
|
|
|
2016-07-01 00:08:44 +00:00
|
|
|
/**
|
|
|
|
|
* @var bool|PPFuzzTest
|
|
|
|
|
*/
|
2014-04-22 21:07:08 +00:00
|
|
|
private static $currentTest = false;
|
2007-11-20 11:07:22 +00:00
|
|
|
|
2021-09-04 01:42:33 +00:00
|
|
|
/**
|
|
|
|
|
* @return void|never
|
|
|
|
|
*/
|
2019-10-09 18:41:33 +00:00
|
|
|
public function execute() {
|
2007-11-20 11:07:22 +00:00
|
|
|
if ( !file_exists( 'results' ) ) {
|
|
|
|
|
mkdir( 'results' );
|
|
|
|
|
}
|
|
|
|
|
if ( !is_dir( 'results' ) ) {
|
|
|
|
|
echo "Unable to create 'results' directory\n";
|
|
|
|
|
exit( 1 );
|
|
|
|
|
}
|
2008-01-24 04:29:56 +00:00
|
|
|
$overallStart = microtime( true );
|
|
|
|
|
$reportInterval = 1000;
|
2020-06-15 10:46:22 +00:00
|
|
|
// @phan-suppress-next-line PhanInfiniteLoop
|
2008-01-24 04:29:56 +00:00
|
|
|
for ( $i = 1; true; $i++ ) {
|
|
|
|
|
$t = -microtime( true );
|
2007-11-20 11:07:22 +00:00
|
|
|
try {
|
|
|
|
|
self::$currentTest = new PPFuzzTest( $this );
|
|
|
|
|
self::$currentTest->execute();
|
2008-01-24 04:29:56 +00:00
|
|
|
$passed = 'passed';
|
2015-01-09 23:44:47 +00:00
|
|
|
} catch ( Exception $e ) {
|
2007-11-20 11:07:22 +00:00
|
|
|
$testReport = self::$currentTest->getReport();
|
2019-08-31 16:14:38 +00:00
|
|
|
$exceptionReport = $e instanceof MWException ? $e->getText() : (string)$e;
|
2007-11-20 11:07:22 +00:00
|
|
|
$hash = md5( $testReport );
|
|
|
|
|
file_put_contents( "results/ppft-$hash.in", serialize( self::$currentTest ) );
|
2010-05-22 16:50:39 +00:00
|
|
|
file_put_contents( "results/ppft-$hash.fail",
|
2007-11-20 11:07:22 +00:00
|
|
|
"Input:\n$testReport\n\nException report:\n$exceptionReport\n" );
|
|
|
|
|
print "Test $hash failed\n";
|
2008-01-24 04:29:56 +00:00
|
|
|
$passed = 'failed';
|
2007-11-20 11:07:22 +00:00
|
|
|
}
|
2008-01-24 04:29:56 +00:00
|
|
|
$t += microtime( true );
|
|
|
|
|
|
|
|
|
|
if ( $this->verbose ) {
|
|
|
|
|
printf( "Test $passed in %.3f seconds\n", $t );
|
|
|
|
|
print self::$currentTest->getReport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$reportMetric = ( microtime( true ) - $overallStart ) / $i * $reportInterval;
|
|
|
|
|
if ( $reportMetric > 25 ) {
|
|
|
|
|
if ( substr( $reportInterval, 0, 1 ) === '1' ) {
|
|
|
|
|
$reportInterval /= 2;
|
|
|
|
|
} else {
|
|
|
|
|
$reportInterval /= 5;
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $reportMetric < 4 ) {
|
|
|
|
|
if ( substr( $reportInterval, 0, 1 ) === '1' ) {
|
|
|
|
|
$reportInterval *= 5;
|
|
|
|
|
} else {
|
|
|
|
|
$reportInterval *= 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( $i % $reportInterval == 0 ) {
|
2007-11-20 11:07:22 +00:00
|
|
|
print "$i tests done\n";
|
|
|
|
|
/*
|
|
|
|
|
$testReport = self::$currentTest->getReport();
|
|
|
|
|
$filename = 'results/ppft-' . md5( $testReport ) . '.pass';
|
|
|
|
|
file_put_contents( $filename, "Input:\n$testReport\n" );*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
public function makeInputText( $max = false ) {
|
2008-01-24 04:29:56 +00:00
|
|
|
if ( $max === false ) {
|
|
|
|
|
$max = $this->maxLength;
|
|
|
|
|
}
|
|
|
|
|
$length = mt_rand( $this->minLength, $max );
|
2007-11-20 11:07:22 +00:00
|
|
|
$s = '';
|
|
|
|
|
for ( $i = 0; $i < $length; $i++ ) {
|
|
|
|
|
$hairIndex = mt_rand( 0, count( $this->hairs ) - 1 );
|
|
|
|
|
$s .= $this->hairs[$hairIndex];
|
|
|
|
|
}
|
|
|
|
|
// Send through the UTF-8 normaliser
|
2010-12-04 03:20:14 +00:00
|
|
|
// This resolves a few differences between the old preprocessor and the
|
2007-11-20 11:07:22 +00:00
|
|
|
// XML-based one, which doesn't like illegals and converts line endings.
|
|
|
|
|
// It's done by the MW UI, so it's a reasonably legitimate thing to do.
|
2018-07-29 12:24:54 +00:00
|
|
|
$s = MediaWikiServices::getInstance()->getContentLanguage()->normalize( $s );
|
2014-04-23 18:09:13 +00:00
|
|
|
|
2007-11-20 11:07:22 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
public function makeTitle() {
|
2007-11-20 11:07:22 +00:00
|
|
|
return Title::newFromText( mt_rand( 0, 1000000 ), mt_rand( 0, 10 ) );
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-21 16:36:08 +00:00
|
|
|
/*
|
2019-10-11 19:07:32 +00:00
|
|
|
public function pickOutputType() {
|
2007-11-20 11:07:22 +00:00
|
|
|
$count = count( $this->outputTypes );
|
|
|
|
|
return $this->outputTypes[ mt_rand( 0, $count - 1 ) ];
|
2008-01-21 16:36:08 +00:00
|
|
|
}*/
|
|
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
public function pickEntryPoint() {
|
2008-01-21 16:36:08 +00:00
|
|
|
$count = count( $this->entryPoints );
|
2014-04-23 18:09:13 +00:00
|
|
|
|
|
|
|
|
return $this->entryPoints[mt_rand( 0, $count - 1 )];
|
2007-11-20 11:07:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PPFuzzTest {
|
2019-10-11 14:45:54 +00:00
|
|
|
/**
|
|
|
|
|
* @var array[]
|
|
|
|
|
* @phan-var array<string,array{text:string|false,finalTitle:Title}>
|
|
|
|
|
*/
|
|
|
|
|
public $templates;
|
|
|
|
|
public $mainText, $title, $entryPoint, $output;
|
2007-11-20 11:07:22 +00:00
|
|
|
|
2019-09-09 09:11:50 +00:00
|
|
|
/** @var PPFuzzTester */
|
|
|
|
|
private $parent;
|
|
|
|
|
/** @var string */
|
|
|
|
|
public $nickname;
|
|
|
|
|
/** @var bool */
|
|
|
|
|
public $fancySig;
|
|
|
|
|
|
2019-09-08 16:59:52 +00:00
|
|
|
/**
|
|
|
|
|
* @param PPFuzzTester $tester
|
|
|
|
|
*/
|
2019-10-09 18:41:33 +00:00
|
|
|
public function __construct( $tester ) {
|
2008-01-24 04:29:56 +00:00
|
|
|
global $wgMaxSigChars;
|
2007-11-20 11:07:22 +00:00
|
|
|
$this->parent = $tester;
|
|
|
|
|
$this->mainText = $tester->makeInputText();
|
|
|
|
|
$this->title = $tester->makeTitle();
|
2010-05-22 16:50:39 +00:00
|
|
|
// $this->outputType = $tester->pickOutputType();
|
2008-01-21 16:36:08 +00:00
|
|
|
$this->entryPoint = $tester->pickEntryPoint();
|
2010-05-22 16:50:39 +00:00
|
|
|
$this->nickname = $tester->makeInputText( $wgMaxSigChars + 10 );
|
2008-01-21 16:36:08 +00:00
|
|
|
$this->fancySig = (bool)mt_rand( 0, 1 );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->templates = [];
|
2007-11-20 11:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 02:25:19 +00:00
|
|
|
/**
|
2014-04-17 20:48:32 +00:00
|
|
|
* @param Title $title
|
2014-08-25 16:50:35 +00:00
|
|
|
* @return array
|
2011-07-01 02:25:19 +00:00
|
|
|
*/
|
2019-10-11 19:07:32 +00:00
|
|
|
public function templateHook( $title ) {
|
2007-11-20 11:07:22 +00:00
|
|
|
$titleText = $title->getPrefixedDBkey();
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2007-11-20 11:07:22 +00:00
|
|
|
if ( !isset( $this->templates[$titleText] ) ) {
|
|
|
|
|
$finalTitle = $title;
|
|
|
|
|
if ( count( $this->templates ) >= $this->parent->maxTemplates ) {
|
|
|
|
|
// Too many templates
|
|
|
|
|
$text = false;
|
|
|
|
|
} else {
|
|
|
|
|
if ( !mt_rand( 0, 1 ) ) {
|
|
|
|
|
// Redirect
|
|
|
|
|
$finalTitle = $this->parent->makeTitle();
|
|
|
|
|
}
|
|
|
|
|
if ( !mt_rand( 0, 5 ) ) {
|
|
|
|
|
// Doesn't exist
|
|
|
|
|
$text = false;
|
|
|
|
|
} else {
|
|
|
|
|
$text = $this->parent->makeInputText();
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->templates[$titleText] = [
|
2007-11-20 11:07:22 +00:00
|
|
|
'text' => $text,
|
2016-02-17 09:09:32 +00:00
|
|
|
'finalTitle' => $finalTitle ];
|
2007-11-20 11:07:22 +00:00
|
|
|
}
|
2014-04-23 18:09:13 +00:00
|
|
|
|
2007-11-20 11:07:22 +00:00
|
|
|
return $this->templates[$titleText];
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 18:41:33 +00:00
|
|
|
public function execute() {
|
2020-06-05 01:37:01 +00:00
|
|
|
$user = new PPFuzzUser;
|
|
|
|
|
$user->mName = 'Fuzz';
|
|
|
|
|
$user->mFrom = 'name';
|
|
|
|
|
$user->ppfz_test = $this;
|
2008-01-21 16:36:08 +00:00
|
|
|
|
2021-09-04 19:19:47 +00:00
|
|
|
StubGlobalUser::setUser( $user );
|
2020-06-05 01:37:01 +00:00
|
|
|
|
|
|
|
|
$options = ParserOptions::newFromUser( $user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$options->setTemplateCallback( [ $this, 'templateHook' ] );
|
2008-01-24 04:29:56 +00:00
|
|
|
$options->setTimestamp( wfTimestampNow() );
|
2014-04-22 21:07:08 +00:00
|
|
|
$this->output = call_user_func(
|
Deprecate Parser implementation methods (will be private in next release)
The following public methods were renamed and made private; the old name
is hard-deprecated and calls the new renamed private method:
Parser::doMagicLinks() => handleMagicLinks()
Parser::doDoubleUnderscore() => handleMagicLinks()
Parser::doHeadings() => handleHeadings()
Parser::doAllQuotes() => handleAllQuotes()
Parser::replaceExternalLinks() => handleExternalLinks()
Parser::replaceInternalLinks() => handleInternalLinks()
Parser::replaceInternalLinks2() => handleInternalLinks2()
Parser::getVariableValue() => expandMagicVariable()
Parser::initialiseVariables() => initializeVariables()
Parser::formatHeadings() => finalizeHeadings()
Parser::test{Pst,Preprocess,Srvus}() => fuzzTest{Pst,Preprocess,Srvus}()
Additionally, the following methods are not used externally, but are
used outside the Parser class by core code. They have been marked
@internal:
Parser::doQuotes() (used by {{#displaytitle}}),
Parser::getExternalLink{Rel,Attribs}() (used by Linker),
Parser::normalizeLinkUrl() (used by Special:LinkSearch and elsewhere).
Parser::{brace,arg,extension}Substitution() (used by PPFrame)
Code search query:
https://codesearch.wmflabs.org/deployed/?q=do%28MagicLinks%7CDoubleUnderscore%7CHeadings%7CAllQuotes%29%7Creplace%28ExternalLinks%7CInternalLinks%28%7C2%29%29%7CgetVariableValue%7CinitialiseVariables%7CformatHeadings%7Ctest%28Pst%7CPreprocess%7CSrvus%29%7CdoQuotes%7CgetExternalLink%28Rel%7CAttribs%29%7CnormalizeLinkUrl%7C%28brace%2Carg%2Cextension%29Substitution&i=nope&files=&repos=
Bug: T236810
Change-Id: I19a43ffc5dcfdd2981b51079c33422c964acb076
2019-10-28 19:52:50 +00:00
|
|
|
[ TestingAccessWrapper::newFromObject(
|
|
|
|
|
MediaWikiServices::getInstance()->getParser()
|
|
|
|
|
), $this->entryPoint ],
|
2014-04-22 21:07:08 +00:00
|
|
|
$this->mainText,
|
|
|
|
|
$this->title,
|
|
|
|
|
$options
|
|
|
|
|
);
|
|
|
|
|
|
2008-01-24 04:29:56 +00:00
|
|
|
return $this->output;
|
2007-11-20 11:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
public function getReport() {
|
2007-11-20 11:07:22 +00:00
|
|
|
$s = "Title: " . $this->title->getPrefixedDBkey() . "\n" .
|
2020-05-10 00:09:19 +00:00
|
|
|
// "Output type: {$this->outputType}\n" .
|
2010-05-22 16:50:39 +00:00
|
|
|
"Entry point: {$this->entryPoint}\n" .
|
2014-04-22 21:07:08 +00:00
|
|
|
"User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) .
|
2014-04-23 18:09:13 +00:00
|
|
|
' ' . var_export( $this->nickname, true ) . "\n" .
|
2007-11-20 11:07:22 +00:00
|
|
|
"Main text: " . var_export( $this->mainText, true ) . "\n";
|
|
|
|
|
foreach ( $this->templates as $titleText => $template ) {
|
|
|
|
|
$finalTitle = $template['finalTitle'];
|
|
|
|
|
if ( $finalTitle != $titleText ) {
|
|
|
|
|
$s .= "[[$titleText]] -> [[$finalTitle]]: " . var_export( $template['text'], true ) . "\n";
|
|
|
|
|
} else {
|
|
|
|
|
$s .= "[[$titleText]]: " . var_export( $template['text'], true ) . "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-01-24 04:29:56 +00:00
|
|
|
$s .= "Output: " . var_export( $this->output, true ) . "\n";
|
2014-04-22 21:07:08 +00:00
|
|
|
|
2007-11-20 11:07:22 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-21 16:36:08 +00:00
|
|
|
class PPFuzzUser extends User {
|
2012-09-14 18:57:14 +00:00
|
|
|
public $ppfz_test, $mDataLoaded;
|
2008-01-21 16:36:08 +00:00
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
public function load( $flags = null ) {
|
2008-01-24 04:29:56 +00:00
|
|
|
if ( $this->mDataLoaded ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->mDataLoaded = true;
|
|
|
|
|
$this->loadDefaults( $this->mName );
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 19:07:32 +00:00
|
|
|
public function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
|
2011-06-14 15:08:52 +00:00
|
|
|
if ( $oname === 'fancysig' ) {
|
2008-01-21 16:36:08 +00:00
|
|
|
return $this->ppfz_test->fancySig;
|
2011-06-14 15:08:52 +00:00
|
|
|
} elseif ( $oname === 'nickname' ) {
|
2008-01-21 16:36:08 +00:00
|
|
|
return $this->ppfz_test->nickname;
|
|
|
|
|
} else {
|
2011-06-14 15:08:52 +00:00
|
|
|
return parent::getOption( $oname, $defaultOverride, $ignoreHidden );
|
2008-01-21 16:36:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-20 11:07:22 +00:00
|
|
|
ini_set( 'memory_limit', '50M' );
|
|
|
|
|
if ( isset( $args[0] ) ) {
|
|
|
|
|
$testText = file_get_contents( $args[0] );
|
|
|
|
|
if ( !$testText ) {
|
|
|
|
|
print "File not found\n";
|
|
|
|
|
exit( 1 );
|
|
|
|
|
}
|
|
|
|
|
$test = unserialize( $testText );
|
|
|
|
|
$result = $test->execute();
|
2008-01-24 04:29:56 +00:00
|
|
|
print "Test passed.\n";
|
2007-11-20 11:07:22 +00:00
|
|
|
} else {
|
|
|
|
|
$tester = new PPFuzzTester;
|
2008-01-24 04:29:56 +00:00
|
|
|
$tester->verbose = isset( $options['verbose'] );
|
2007-11-20 11:07:22 +00:00
|
|
|
$tester->execute();
|
|
|
|
|
}
|