MediaWiki
REL1_24
|
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. | |
requireTransparentHook ($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 (ParserTestResult $testResult) | |
Refactored in 1.22 to use ParserTestResult. | |
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 () |
static | setupInterwikis () |
Insert hardcoded interwiki in the lookup table. | |
static | tearDownInterwikis () |
Remove the hardcoded interwiki lookup table. | |
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 (ParserTestResult $testResult) | |
Print a failure message and provide some explanatory output about what went wrong if so configured. | |
showSkipped () | |
Print a skipped message. | |
showSuccess (ParserTestResult $testResult) | |
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. | |
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 | |
bool | $color |
$color whereas output should be colorized | |
bool | $databaseSetupDone = false |
$databaseSetupDone True if the database has been set up | |
DatabaseBase | $db |
Our connection to the database. | |
CloneDatabase | $dbClone |
Database clone helper. | |
DjVuSupport | $djVuSupport |
$fuzzSeed = 0 | |
$maxFuzzTestLength = 300 | |
$memoryLimit = 50 | |
$savedGlobals = array() | |
bool | $showOutput |
$showOutput Show test output | |
TidySupport | $tidySupport |
$uploadDir = null | |
bool | $useTemporaryTables = true |
$useTemporaryTables Use temporary tables for the temporary database |
Definition at line 34 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).
array | $options |
Definition at line 82 of file parserTest.inc.
Definition at line 469 of file parserTest.inc.
static ParserTest::addArticle | ( | $ | name, |
$ | text, | ||
$ | line = 'unknown' , |
||
$ | ignoreDuplicate = '' |
||
) | [static] |
Insert a temporary test article.
string | $name | The title, including any prefix |
string | $text | The article text |
int | $line | The input line number, for reporting errors |
bool | $ignoreDuplicate | Whether to silently ignore duplicate pages |
Definition at line 1491 of file parserTest.inc.
References $name, $title, chomp(), WikiPage\factory(), global, ContentHandler\makeContent(), and Title\newFromText().
static ParserTest::chomp | ( | $ | s | ) | [static] |
Remove last character if it is a newline utility.
string | $s |
Definition at line 329 of file parserTest.inc.
Referenced by addArticle(), TestFileIterator\readNextTest(), and TestFileIterator\setupCurrentTest().
ParserTest::cleanupOption | ( | $ | opt | ) | [private] |
Definition at line 762 of file parserTest.inc.
ParserTest::colorDiff | ( | $ | text | ) | [protected] |
Colorize unified diff output if set for ANSI color output.
Subtractions are colored blue, additions red.
string | $text |
Definition at line 1464 of file parserTest.inc.
static ParserTest::deleteDirs | ( | $ | dirs | ) | [static, private] |
Delete the specified directories, if they exist.
Must be empty.
array | $dirs | Full paths to directories to delete. |
Definition at line 1327 of file parserTest.inc.
static ParserTest::deleteFiles | ( | $ | files | ) | [static, private] |
Delete the specified files, if they exist.
array | $files | Full paths to files to delete. |
Definition at line 1315 of file parserTest.inc.
ParserTest::dumpToFile | ( | $ | data, |
$ | filename | ||
) | [private] |
Write the given string to a file, adding a final newline.
string | $data | |
string | $filename |
Definition at line 1451 of file parserTest.inc.
ParserTest::extractFragment | ( | $ | text, |
$ | position | ||
) | [private] |
Definition at line 1618 of file parserTest.inc.
ParserTest::fuzzTest | ( | $ | filenames | ) |
Run a fuzz test series Draw input from a set of test files.
array | $filenames |
Definition at line 342 of file parserTest.inc.
static ParserTest::getFakeTimestamp | ( | &$ | parser, |
&$ | ts | ||
) | [static] |
Definition at line 1643 of file parserTest.inc.
ParserTest::getFuzzInput | ( | $ | filenames | ) |
Get an input dictionary from a set of parser test files.
array | $filenames |
Definition at line 414 of file parserTest.inc.
static ParserTest::getOptionValue | ( | $ | key, |
$ | opts, | ||
$ | default | ||
) | [static, private] |
Use a regex to find out the value of an option.
string | $key | Name of option val to retrieve |
array | $opts | Options array to look in |
mixed | $default | Default value returned if not found |
Definition at line 680 of file parserTest.inc.
References $key.
Referenced by setupGlobals().
ParserTest::getParser | ( | $ | preprocessor = null | ) |
Get a Parser object.
string | $preprocessor |
Definition at line 535 of file parserTest.inc.
ParserTest::listTables | ( | ) | [private] |
List of temporary tables to create, without prefix.
Some of these probably aren't necessary.
Definition at line 932 of file parserTest.inc.
ParserTest::parseOptions | ( | $ | instring | ) | [private] |
Definition at line 690 of file parserTest.inc.
References $key.
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.
string | $input | |
string | $output | |
string | $inFileTail | Tailing for the input file name |
string | $outFileTail | Tailing for the output file name |
Definition at line 1417 of file parserTest.inc.
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.
string | $name |
Definition at line 1553 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.
string | $name |
Definition at line 1530 of file parserTest.inc.
ParserTest::requireTransparentHook | ( | $ | 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.
string | $name |
Definition at line 1576 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.
string | $desc | Test's description |
string | $input | Wikitext to try rendering |
string | $result | Result to output |
array | $opts | Test's options |
string | $config | Overrides for global variables, one per line |
Definition at line 571 of file parserTest.inc.
ParserTest::runTests | ( | $ | tests | ) |
Definition at line 512 of file parserTest.inc.
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.
array | $filenames | Array of strings |
Definition at line 484 of file parserTest.inc.
static ParserTest::setUp | ( | ) | [static] |
Definition at line 148 of file parserTest.inc.
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 959 of file parserTest.inc.
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.
string | $opts | |
string | $config |
Definition at line 784 of file parserTest.inc.
References $GLOBALS, $IP, $value, $wgHooks, array(), as, MagicWord\clearCache(), Language\factory(), getOptionValue(), global, list, and wfRunHooks().
static ParserTest::setupInterwikis | ( | ) | [static] |
Insert hardcoded interwiki in the lookup table.
This function insert a set of well known interwikis that are used in the parser tests. They can be considered has fixtures are injected in the interwiki cache by using the 'InterwikiLoadPrefix' hook. Since we are not interested in looking up interwikis in the database, the hook completely replace the existing mechanism (hook returns false).
Definition at line 239 of file parserTest.inc.
Referenced by NewParserTest\setUpBeforeClass().
ParserTest::setupRecorder | ( | $ | options | ) |
Definition at line 311 of file parserTest.inc.
References Hooks\clear().
ParserTest::setupUploadDir | ( | ) | [private] |
Create a dummy uploads directory which will contain a couple of files in order to pass existence tests.
Definition at line 1160 of file parserTest.inc.
ParserTest::showFailure | ( | ParserTestResult $ | testResult | ) | [protected] |
Print a failure message and provide some explanatory output about what went wrong if so configured.
Refactored in 1.22 to use ParserTestResult
ParserTestResult | $testResult |
Definition at line 1368 of file parserTest.inc.
ParserTest::showRunFile | ( | $ | path | ) |
Show "Reading tests from ...".
string | $path |
Definition at line 1477 of file parserTest.inc.
ParserTest::showSkipped | ( | ) | [protected] |
ParserTest::showSuccess | ( | ParserTestResult $ | testResult | ) | [protected] |
Print a happy success message.
Refactored in 1.22 to use ParserTestResult
ParserTestResult | $testResult |
Definition at line 1351 of file parserTest.inc.
ParserTest::showTesting | ( | $ | desc | ) | [protected] |
ParserTest::showTestResult | ( | ParserTestResult $ | testResult | ) |
Refactored in 1.22 to use ParserTestResult.
ParserTestResult | $testResult |
Definition at line 663 of file parserTest.inc.
Definition at line 1114 of file parserTest.inc.
ParserTest::teardownGlobals | ( | ) | [private] |
Restore default values and perform any necessary clean-up after each test runs.
Definition at line 1200 of file parserTest.inc.
static ParserTest::tearDownInterwikis | ( | ) | [static] |
Remove the hardcoded interwiki lookup table.
Definition at line 307 of file parserTest.inc.
Referenced by NewParserTest\tearDownAfterClass().
ParserTest::teardownUploadDir | ( | $ | dir | ) | [private] |
Remove the dummy uploads directory.
string | $dir |
Definition at line 1215 of file parserTest.inc.
ParserTest::wellFormed | ( | $ | text | ) | [private] |
Definition at line 1591 of file parserTest.inc.
bool ParserTest::$color [private] |
$color whereas output should be colorized
Definition at line 37 of file parserTest.inc.
bool ParserTest::$databaseSetupDone = false [private] |
$databaseSetupDone True if the database has been set up
Definition at line 49 of file parserTest.inc.
DatabaseBase ParserTest::$db [private] |
Our connection to the database.
Definition at line 54 of file parserTest.inc.
CloneDatabase ParserTest::$dbClone [private] |
Database clone helper.
Definition at line 59 of file parserTest.inc.
DjVuSupport ParserTest::$djVuSupport [private] |
Definition at line 63 of file parserTest.inc.
ParserTest::$fuzzSeed = 0 [private] |
Definition at line 70 of file parserTest.inc.
ParserTest::$maxFuzzTestLength = 300 [private] |
Definition at line 69 of file parserTest.inc.
ParserTest::$memoryLimit = 50 [private] |
Definition at line 71 of file parserTest.inc.
ParserTest::$regex = "" |
Definition at line 74 of file parserTest.inc.
ParserTest::$savedGlobals = array() [private] |
Definition at line 75 of file parserTest.inc.
bool ParserTest::$showOutput [private] |
$showOutput Show test output
Definition at line 41 of file parserTest.inc.
TidySupport ParserTest::$tidySupport [private] |
Definition at line 67 of file parserTest.inc.
ParserTest::$uploadDir = null [private] |
Definition at line 72 of file parserTest.inc.
bool ParserTest::$useTemporaryTables = true [private] |
$useTemporaryTables Use temporary tables for the temporary database
Definition at line 45 of file parserTest.inc.