MediaWiki
REL1_19
|
Public Member Functions | |
__construct ($options=array()) | |
Sets terminal colorization and diff/quick modes depending on OS and command-line options (--color and --quick). | |
abort () | |
fuzzTest ($filenames) | |
Run a fuzz test series Draw input from a set of test files. | |
getFuzzInput ($filenames) | |
Get an input dictionary from a set of parser test files. | |
getMemoryBreakdown () | |
Get a memory usage breakdown. | |
getParser ($preprocessor=null) | |
Get a Parser object. | |
requireFunctionHook ($name) | |
Steal a callback function from the primary parser, save it for application to our scary parser. | |
requireHook ($name) | |
Steal a callback function from the primary parser, save it for application to our scary parser. | |
runTest ($desc, $input, $result, $opts, $config) | |
Run a given wikitext input through a freshly-constructed wiki parser, and compare the output against the expected results. | |
runTests ($tests) | |
runTestsFromFiles ($filenames) | |
Run a series of tests listed in the given text files. | |
setupDatabase () | |
Set up a temporary set of wiki tables to work with for the tests. | |
setupRecorder ($options) | |
showRunFile ($path) | |
Show "Reading tests from ...". | |
showTestResult ($desc, $result, $out) | |
teardownDatabase () | |
Static Public Member Functions | |
static | addArticle ($name, $text, $line= 'unknown', $ignoreDuplicate= '') |
Insert a temporary test article. | |
static | chomp ($s) |
Remove last character if it is a newline utility. | |
static | getFakeTimestamp (&$parser, &$ts) |
static | setUp () |
Public Attributes | |
$regex = "" | |
Protected Member Functions | |
colorDiff ($text) | |
Colorize unified diff output if set for ANSI color output. | |
quickDiff ($input, $output, $inFileTail= 'expected', $outFileTail= 'actual') | |
Run given strings through a diff and return the (colorized) output. | |
showFailure ($desc, $result, $html) | |
Print a failure message and provide some explanatory output about what went wrong if so configured. | |
showSuccess ($desc) | |
Print a happy success message. | |
showTesting ($desc) | |
"Running test $desc..." | |
Private Member Functions | |
cleanupOption ($opt) | |
dumpToFile ($data, $filename) | |
Write the given string to a file, adding a final newline. | |
extractFragment ($text, $position) | |
listTables () | |
List of temporary tables to create, without prefix. | |
parseOptions ($instring) | |
setupGlobals ($opts= '', $config= '') | |
Set up the global variables for a consistent environment for each test. | |
setupUploadDir () | |
Create a dummy uploads directory which will contain a couple of files in order to pass existence tests. | |
teardownGlobals () | |
Restore default values and perform any necessary clean-up after each test runs. | |
teardownUploadDir ($dir) | |
Remove the dummy uploads directory. | |
tidy ($text) | |
Run the "tidy" command on text if the $wgUseTidy global is true. | |
wellFormed ($text) | |
Static Private Member Functions | |
static | deleteDirs ($dirs) |
Delete the specified directories, if they exist. | |
static | deleteFiles ($files) |
Delete the specified files, if they exist. | |
static | getOptionValue ($key, $opts, $default) |
Use a regex to find out the value of an option. | |
Private Attributes | |
$color | |
boolean $color whereas output should be colorized | |
$databaseSetupDone = false | |
boolean $databaseSetupDone True if the database has been set up | |
$db | |
$dbClone | |
$fuzzSeed = 0 | |
$maxFuzzTestLength = 300 | |
$memoryLimit = 50 | |
$oldTablePrefix | |
string $oldTablePrefix Original table prefix | |
$savedGlobals = array() | |
$showOutput | |
boolean $showOutput Show test output | |
$uploadDir = null | |
$useTemporaryTables = true | |
boolean $useTemporaryTables Use temporary tables for the temporary database |
Definition at line 30 of file parserTest.inc.
ParserTest::__construct | ( | $ | options = array() | ) |
Sets terminal colorization and diff/quick modes depending on OS and command-line options (--color and --quick).
Definition at line 79 of file parserTest.inc.
References $options, echo, Maintenance\posix_isatty(), setUp(), setupRecorder(), showDiffs(), showFailure(), and wfIsWindows().
Definition at line 353 of file parserTest.inc.
Referenced by fuzzTest().
static ParserTest::addArticle | ( | $ | name, |
$ | text, | ||
$ | line = 'unknown' , |
||
$ | ignoreDuplicate = '' |
||
) | [static] |
Insert a temporary test article.
$name | String: the title, including any prefix |
$text | String: the article text |
$line | Integer: the input line number, for reporting errors |
$ignoreDuplicate | Boolean: whether to silently ignore duplicate pages |
Definition at line 1166 of file parserTest.inc.
References $page, $title, $wgCapitalLinks, chomp(), WikiPage\factory(), and Title\newFromText().
static ParserTest::chomp | ( | $ | s | ) | [static] |
Remove last character if it is a newline utility.
Definition at line 220 of file parserTest.inc.
Referenced by addArticle(), and TestFileIterator\readNextTest().
ParserTest::cleanupOption | ( | $ | opt | ) | [private] |
Definition at line 598 of file parserTest.inc.
Referenced by parseOptions().
ParserTest::colorDiff | ( | $ | text | ) | [protected] |
Colorize unified diff output if set for ANSI color output.
Subtractions are colored blue, additions red.
$text | String |
Definition at line 1139 of file parserTest.inc.
Referenced by quickDiff().
static ParserTest::deleteDirs | ( | $ | dirs | ) | [static, private] |
Delete the specified directories, if they exist.
Must be empty.
$dirs | Array: full paths to directories to delete. |
Definition at line 1022 of file parserTest.inc.
References $dir.
Referenced by teardownUploadDir().
static ParserTest::deleteFiles | ( | $ | files | ) | [static, private] |
Delete the specified files, if they exist.
$files | Array: full paths to files to delete. |
Definition at line 1010 of file parserTest.inc.
Referenced by teardownUploadDir().
ParserTest::dumpToFile | ( | $ | data, |
$ | filename | ||
) | [private] |
Write the given string to a file, adding a final newline.
$data | String |
$filename | String |
Definition at line 1126 of file parserTest.inc.
References $file.
Referenced by quickDiff().
ParserTest::extractFragment | ( | $ | text, |
$ | position | ||
) | [private] |
Definition at line 1287 of file parserTest.inc.
Referenced by wellFormed().
ParserTest::fuzzTest | ( | $ | filenames | ) |
Run a fuzz test series Draw input from a set of test files.
Definition at line 233 of file parserTest.inc.
References $input, $title, $user, abort(), echo, Language\factory(), getFuzzInput(), getMemoryBreakdown(), getParser(), Title\makeTitle(), ParserOptions\newFromUser(), setupDatabase(), setupGlobals(), and teardownGlobals().
static ParserTest::getFakeTimestamp | ( | &$ | parser, |
&$ | ts | ||
) | [static] |
Definition at line 1312 of file parserTest.inc.
ParserTest::getFuzzInput | ( | $ | filenames | ) |
Get an input dictionary from a set of parser test files.
Definition at line 303 of file parserTest.inc.
References $matches.
Referenced by fuzzTest().
Get a memory usage breakdown.
Definition at line 321 of file parserTest.inc.
Referenced by fuzzTest().
static ParserTest::getOptionValue | ( | $ | key, |
$ | opts, | ||
$ | default | ||
) | [static, private] |
Use a regex to find out the value of an option.
$key | String: name of option val to retrieve |
$opts | Options array to look in |
$default | Mixed: default value returned if not found |
Definition at line 533 of file parserTest.inc.
Referenced by setupGlobals().
ParserTest::getParser | ( | $ | preprocessor = null | ) |
Get a Parser object.
Definition at line 411 of file parserTest.inc.
References $wgParserConf, and wfRunHooks().
Referenced by fuzzTest(), and runTest().
ParserTest::listTables | ( | ) | [private] |
List of temporary tables to create, without prefix.
Some of these probably aren't necessary.
Definition at line 734 of file parserTest.inc.
References wfRunHooks().
Referenced by setupDatabase(), and teardownDatabase().
ParserTest::parseOptions | ( | $ | instring | ) | [private] |
Definition at line 543 of file parserTest.inc.
References $matches, $regex, and cleanupOption().
Referenced by runTest().
ParserTest::quickDiff | ( | $ | input, |
$ | output, | ||
$ | inFileTail = 'expected' , |
||
$ | outFileTail = 'actual' |
||
) | [protected] |
Run given strings through a diff and return the (colorized) output.
Requires writable /tmp directory and a 'diff' command in the PATH.
$input | String |
$output | String |
$inFileTail | String: tailing for the input file name |
$outFileTail | String: tailing for the output file name |
Definition at line 1095 of file parserTest.inc.
References $input, $output, $wgDiff3, colorDiff(), dumpToFile(), wfEscapeShellArg(), wfIsWindows(), and wfTempDir().
Referenced by showFailure().
ParserTest::requireFunctionHook | ( | $ | name | ) |
Steal a callback function from the primary parser, save it for application to our scary parser.
If the hook is not installed, abort processing of this file.
$name | String |
Definition at line 1228 of file parserTest.inc.
ParserTest::requireHook | ( | $ | name | ) |
Steal a callback function from the primary parser, save it for application to our scary parser.
If the hook is not installed, abort processing of this file.
$name | String |
Definition at line 1205 of file parserTest.inc.
ParserTest::runTest | ( | $ | desc, |
$ | input, | ||
$ | result, | ||
$ | opts, | ||
$ | config | ||
) |
Run a given wikitext input through a freshly-constructed wiki parser, and compare the output against the expected results.
Prints status and explanatory messages to stdout.
$desc | String: test's description |
$input | String: wikitext to try rendering |
$result | String: result to output |
$opts | Array: test's options |
$config | String: overrides for global variables, one per line |
Definition at line 443 of file parserTest.inc.
References $input, $options, $out, $output, $result, $section, $title, $user, Linker\formatComment(), getParser(), ParserOptions\newFromContext(), Title\newFromText(), parseOptions(), setupGlobals(), showTesting(), showTestResult(), teardownGlobals(), and tidy().
Referenced by runTests().
ParserTest::runTests | ( | $ | tests | ) |
Definition at line 391 of file parserTest.inc.
References $ok, $result, $t, print, and runTest().
Referenced by runTestsFromFiles().
ParserTest::runTestsFromFiles | ( | $ | filenames | ) |
Run a series of tests listed in the given text files.
Each test consists of a brief description, wikitext input, and the expected HTML output.
Prints status updates on stdout and counts up the total number and percentage of passed tests.
$filenames | Array of strings |
Definition at line 368 of file parserTest.inc.
References $ok, echo, Language\factory(), runTests(), setupDatabase(), and teardownDatabase().
static ParserTest::setUp | ( | ) | [static] |
Definition at line 137 of file parserTest.inc.
References $IP, $messageMemc, $parserMemc, $wgArticlePath, $wgEnableParserCache, $wgExtensionAssetsPath, $wgLang, $wgLocalFileRepo, $wgMainCacheType, $wgMemc, $wgMessageCacheType, $wgNamespaceAliases, $wgNamespaceProtection, $wgOut, $wgParser, $wgParserCacheType, $wgParserConf, $wgScript, $wgScriptPath, $wgStyleDirectory, $wgStylePath, $wgStyleSheetPath, $wgThumbnailScriptPath, $wgUser, DeferredUpdates\clearPendingUpdates(), RequestContext\getLanguage(), wfGetMainCache(), wfGetMessageCacheStorage(), wfGetParserCacheStorage(), and wfTempDir().
Referenced by __construct().
Set up a temporary set of wiki tables to work with for the tests.
Currently this will only be done once per run, and any changes to the db will be visible to later tests in the run.
Definition at line 761 of file parserTest.inc.
References ObjectCache\$instances, $user, $wgDBprefix, User\createNew(), Language\getLocalisationCache(), listTables(), Title\makeTitle(), setupUploadDir(), MessageCache\singleton(), wfBaseConvert(), wfGetDB(), wfGetLB(), and wfLocalFile().
Referenced by fuzzTest(), and runTestsFromFiles().
ParserTest::setupGlobals | ( | $ | opts = '' , |
$ | config = '' |
||
) | [private] |
Set up the global variables for a consistent environment for each test.
Ideally this should replace the global configuration entirely.
Definition at line 613 of file parserTest.inc.
References $wgHooks, MagicWord\clearCache(), Language\factory(), and getOptionValue().
Referenced by fuzzTest(), and runTest().
ParserTest::setupRecorder | ( | $ | options | ) |
Definition at line 204 of file parserTest.inc.
References $options, and SpecialVersion\getVersion().
Referenced by __construct().
ParserTest::setupUploadDir | ( | ) | [private] |
Create a dummy uploads directory which will contain a couple of files in order to pass existence tests.
Definition at line 921 of file parserTest.inc.
References $dir, $IP, wfDebug(), wfMkdirParents(), and wfTempDir().
Referenced by setupDatabase().
ParserTest::showFailure | ( | $ | desc, |
$ | result, | ||
$ | html | ||
) | [protected] |
Print a failure message and provide some explanatory output about what went wrong if so configured.
$desc | String: the test name |
$result | String: expected HTML output |
$html | String: actual HTML output |
Definition at line 1060 of file parserTest.inc.
References $result, print, quickDiff(), showDiffs(), showTesting(), and wellFormed().
Referenced by __construct(), and showTestResult().
ParserTest::showRunFile | ( | $ | path | ) |
Show "Reading tests from ...".
$path | String |
Definition at line 1152 of file parserTest.inc.
References print.
ParserTest::showSuccess | ( | $ | desc | ) | [protected] |
Print a happy success message.
$desc | String: the test name |
Definition at line 1043 of file parserTest.inc.
References print.
Referenced by showTestResult().
ParserTest::showTesting | ( | $ | desc | ) | [protected] |
"Running test $desc..."
Definition at line 1033 of file parserTest.inc.
References print.
Referenced by runTest(), and showFailure().
ParserTest::showTestResult | ( | $ | desc, |
$ | result, | ||
$ | out | ||
) |
Definition at line 517 of file parserTest.inc.
References $out, $result, showFailure(), and showSuccess().
Referenced by runTest().
Definition at line 879 of file parserTest.inc.
References listTables(), teardownGlobals(), teardownUploadDir(), and wfDebug().
Referenced by runTestsFromFiles().
ParserTest::teardownGlobals | ( | ) | [private] |
Restore default values and perform any necessary clean-up after each test runs.
Definition at line 952 of file parserTest.inc.
References RepoGroup\destroySingleton(), and LinkCache\singleton().
Referenced by fuzzTest(), runTest(), and teardownDatabase().
ParserTest::teardownUploadDir | ( | $ | dir | ) | [private] |
Remove the dummy uploads directory.
Definition at line 964 of file parserTest.inc.
References deleteDirs(), and deleteFiles().
Referenced by teardownDatabase().
ParserTest::tidy | ( | $ | text | ) | [private] |
Run the "tidy" command on text if the $wgUseTidy global is true.
$text | String: the text to tidy |
Definition at line 1250 of file parserTest.inc.
References $wgUseTidy.
Referenced by runTest().
ParserTest::wellFormed | ( | $ | text | ) | [private] |
Definition at line 1260 of file parserTest.inc.
References extractFragment(), and Sanitizer\hackDocType().
Referenced by showFailure().
ParserTest::$color [private] |
boolean $color whereas output should be colorized
Definition at line 34 of file parserTest.inc.
ParserTest::$databaseSetupDone = false [private] |
boolean $databaseSetupDone True if the database has been set up
Definition at line 49 of file parserTest.inc.
ParserTest::$db [private] |
Definition at line 55 of file parserTest.inc.
ParserTest::$dbClone [private] |
Definition at line 61 of file parserTest.inc.
ParserTest::$fuzzSeed = 0 [private] |
Definition at line 69 of file parserTest.inc.
ParserTest::$maxFuzzTestLength = 300 [private] |
Definition at line 68 of file parserTest.inc.
ParserTest::$memoryLimit = 50 [private] |
Definition at line 70 of file parserTest.inc.
ParserTest::$oldTablePrefix [private] |
string $oldTablePrefix Original table prefix
Definition at line 66 of file parserTest.inc.
ParserTest::$regex = "" |
Definition at line 73 of file parserTest.inc.
Referenced by parseOptions().
ParserTest::$savedGlobals = array() [private] |
Definition at line 74 of file parserTest.inc.
ParserTest::$showOutput [private] |
boolean $showOutput Show test output
Definition at line 39 of file parserTest.inc.
ParserTest::$uploadDir = null [private] |
Definition at line 71 of file parserTest.inc.
ParserTest::$useTemporaryTables = true [private] |
boolean $useTemporaryTables Use temporary tables for the temporary database
Definition at line 44 of file parserTest.inc.