44 'showProgress' =>
true,
45 'showFailure' =>
true,
46 'showOutput' =>
false,
48 'markWhitespace' =>
false,
50 $this->showDiffs =
$options[
'showDiffs'];
51 $this->showProgress =
$options[
'showProgress'];
53 $this->showOutput =
$options[
'showOutput'];
54 $this->useDwdiff =
$options[
'useDwdiff'];
55 $this->markWhitespace =
$options[
'markWhitespace'];
65 if ( $this->showProgress ) {
71 print "Running test $desc... ";
81 "Running parser tests from \"$path\"..." .
82 $this->
term->reset() .
92 $this->success += ( $result->isSuccess() ? 1 : 0 );
94 if ( $result->isSuccess() ) {
108 if ( $this->showProgress ) {
109 print $this->
term->color(
'1;32' ) .
'PASSED' . $this->
term->reset() .
"\n";
122 if ( !$this->showProgress ) {
123 # In quiet mode we didn't show the 'Testing' message before the
124 # test, in case it succeeded. Show it now:
128 print $this->
term->color(
'31' ) .
'FAILED!' . $this->
term->reset() .
"\n";
130 if ( $this->showOutput ) {
131 print "--- Expected ---\n{$testResult->expected}\n";
132 print "--- Actual ---\n{$testResult->actual}\n";
135 if ( $this->showDiffs ) {
136 print $this->
quickDiff( $testResult->expected, $testResult->actual );
137 if ( !$this->
wellFormed( $testResult->actual ) ) {
138 print "XML error: $this->xmlError\n";
157 $inFileTail =
'expected', $outFileTail =
'actual'
159 if ( $this->markWhitespace ) {
169 # Windows, or at least the fc utility, is retarded
171 $prefix =
wfTempDir() .
"{$slash}mwParser-" . mt_rand();
173 $infile =
"$prefix-$inFileTail";
176 $outfile =
"$prefix-$outFileTail";
184 if ( $this->useDwdiff ) {
185 $shellCommand =
'dwdiff -Pc';
190 $diff =
wfShellExec(
"$shellCommand $shellInfile $shellOutfile" );
195 if ( $this->useDwdiff ) {
209 $file = fopen( $filename,
"wt" );
210 fwrite( $file, $data .
"\n" );
223 [
'/^(-.*)$/m',
'/^(\+.*)$/m' ],
224 [ $this->
term->color( 34 ) .
'$1' . $this->term->reset(),
225 $this->term->color( 31 ) .
'$1' . $this->term->reset() ],
231 Sanitizer::hackDocType() .
236 $parser = xml_parser_create(
"UTF-8" );
238 # case folding violates XML standard, turn it off
239 xml_parser_set_option(
$parser, XML_OPTION_CASE_FOLDING,
false );
242 $err = xml_error_string( xml_get_error_code(
$parser ) );
243 $position = xml_get_current_byte_index(
$parser );
245 $this->xmlError =
"$err at byte $position:\n$fragment";
257 $start = max( 0, $position - 10 );
258 $before = $position - $start;
260 $this->
term->color( 34 ) .
261 substr( $text, $start, $before ) .
262 $this->
term->color( 0 ) .
263 $this->
term->color( 31 ) .
264 $this->
term->color( 1 ) .
265 substr( $text, $position, 1 ) .
266 $this->
term->color( 0 ) .
267 $this->
term->color( 34 ) .
268 substr( $text, $position + 1, 9 ) .
269 $this->
term->color( 0 ) .
271 $display = str_replace(
"\n",
' ', $fragment );
273 str_repeat(
' ', $before ) .
274 $this->
term->color( 31 ) .
276 $this->
term->color( 0 );
278 return "$display\n$caret";
295 if ( $this->showProgress ) {
296 print $this->
term->color(
'1;33' ) .
'SKIPPED' . $this->
term->reset() .
"\n";
302 if ( $this->total > 0 ) {
305 print $this->
term->color( 31 ) .
"No tests found." . $this->
term->reset() .
"\n";
311 print $this->
term->color( 1 ) .
"Passed $success of $total tests ($ratio)";
313 print ", skipped {$this->skipped}";
318 print $this->
term->color( 32 ) .
"ALL TESTS PASSED!";
321 print $this->
term->color( 31 ) .
"$failed tests failed!";
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 >
$wgDiff3
Path to the GNU diff3 utility.
wfTempDir()
Tries to get the system directory for temporary files.
wfPercent( $nr, $acc=2, $round=true)
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
wfIsWindows()
Check if the operating system is Windows.
This is a TestRecorder responsible for printing information about progress, success and failure to th...
showSuccess(ParserTestResult $testResult)
Print a happy success message.
skipped( $test, $subtest)
Mark a test skipped.
startTest( $test)
Called before starting a test.
record( $test, ParserTestResult $result)
Called after each test.
dumpToFile( $data, $filename)
Write the given string to a file, adding a final newline.
reportPercentage( $success, $total)
colorDiff( $text)
Colorize unified diff output if set for ANSI color output.
startSuite( $path)
Show "Reading tests from ...".
warning( $message)
Show a warning to the user.
report()
Called before finishing the test run.
quickDiff( $input, $output, $inFileTail='expected', $outFileTail='actual')
Run given strings through a diff and return the (colorized) output.
endSuite( $path)
Called after ending an input file.
extractFragment( $text, $position)
start()
Called at beginning of the parser test run.
__construct( $term, $options)
showFailure(ParserTestResult $testResult)
Print a failure message and provide some explanatory output about what went wrong if so configured.
Represent the result of a parser test.
Interface to record parser test results.
do that in ParserLimitReportFormat instead $parser
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
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 & $options
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 just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
while(( $__line=Maintenance::readconsole()) !==false) print
if(is_array($mode)) switch( $mode) $input