MediaWiki  master
ParserTestPrinter Class Reference

This is a TestRecorder responsible for printing information about progress, success and failure to the console. More...

Inheritance diagram for ParserTestPrinter:
Collaboration diagram for ParserTestPrinter:

Public Member Functions

 __construct ( $term, $options)
 
 endSuite ( $path)
 
 record ( $test, ParserTestResult $result)
 
 report ()
 
 skipped ( $test, $subtest)
 Mark a test skipped. More...
 
 start ()
 
 startSuite ( $path)
 Show "Reading tests from ...". More...
 
 startTest ( $test)
 
 warning ( $message)
 Show a warning to the user. More...
 
- Public Member Functions inherited from TestRecorder
 end ()
 Called at the end of the parser test run. More...
 
 endSuite ( $path)
 Called after ending an input file. More...
 
 record ( $test, ParserTestResult $result)
 Called after each test. More...
 
 report ()
 Called before finishing the test run. More...
 
 skipped ( $test, $subtest)
 Mark a test skipped. More...
 
 start ()
 Called at beginning of the parser test run. More...
 
 startSuite ( $path)
 Called before starting an input file. More...
 
 startTest ( $test)
 Called before starting a test. More...
 
 warning ( $message)
 Show a warning to the user. More...
 

Private Member Functions

 colorDiff ( $text)
 Colorize unified diff output if set for ANSI color output. More...
 
 dumpToFile ( $data, $filename)
 Write the given string to a file, adding a final newline. More...
 
 extractFragment ( $text, $position)
 
 quickDiff ( $input, $output, $inFileTail='expected', $outFileTail='actual')
 Run given strings through a diff and return the (colorized) output. More...
 
 reportPercentage ( $success, $total)
 
 showFailure (ParserTestResult $testResult)
 Print a failure message and provide some explanatory output about what went wrong if so configured. More...
 
 showSuccess (ParserTestResult $testResult)
 Print a happy success message. More...
 
 showTesting ( $desc)
 
 wellFormed ( $text)
 

Private Attributes

 $markWhitespace
 
 $showDiffs
 
 $showFailure
 
 $showOutput
 
 $showProgress
 
 $skipped
 
 $success
 
 $term
 
 $total
 
 $useDwdiff
 
 $xmlError
 

Detailed Description

This is a TestRecorder responsible for printing information about progress, success and failure to the console.

It is specific to the parserTests.php frontend.

Definition at line 29 of file ParserTestPrinter.php.

Constructor & Destructor Documentation

◆ __construct()

ParserTestPrinter::__construct (   $term,
  $options 
)

Definition at line 42 of file ParserTestPrinter.php.

References $options, $term, showFailure(), and term().

Member Function Documentation

◆ colorDiff()

ParserTestPrinter::colorDiff (   $text)
private

Colorize unified diff output if set for ANSI color output.

Subtractions are colored blue, additions red.

Parameters
string$text
Returns
string

Definition at line 220 of file ParserTestPrinter.php.

References term().

Referenced by quickDiff().

◆ dumpToFile()

ParserTestPrinter::dumpToFile (   $data,
  $filename 
)
private

Write the given string to a file, adding a final newline.

Parameters
string$data
string$filename

Definition at line 207 of file ParserTestPrinter.php.

References $file.

Referenced by quickDiff().

◆ endSuite()

ParserTestPrinter::endSuite (   $path)

Definition at line 88 of file ParserTestPrinter.php.

References print.

◆ extractFragment()

ParserTestPrinter::extractFragment (   $text,
  $position 
)
private

Definition at line 255 of file ParserTestPrinter.php.

References term().

Referenced by wellFormed().

◆ quickDiff()

ParserTestPrinter::quickDiff (   $input,
  $output,
  $inFileTail = 'expected',
  $outFileTail = 'actual' 
)
private

Run given strings through a diff and return the (colorized) output.

Requires writable /tmp directory and a 'diff' command in the PATH.

Parameters
string$input
string$output
string$inFileTailTailing for the input file name
string$outFileTailTailing for the output file name
Returns
string

Definition at line 158 of file ParserTestPrinter.php.

References $input, $output, $wgDiff3, colorDiff(), dumpToFile(), wfIsWindows(), and wfTempDir().

Referenced by showFailure().

◆ record()

ParserTestPrinter::record (   $test,
ParserTestResult  $result 
)

Definition at line 92 of file ParserTestPrinter.php.

References ParserTestResult\isSuccess(), showFailure(), and showSuccess().

◆ report()

ParserTestPrinter::report ( )

Definition at line 300 of file ParserTestPrinter.php.

References print, reportPercentage(), and term().

◆ reportPercentage()

ParserTestPrinter::reportPercentage (   $success,
  $total 
)
private

Definition at line 308 of file ParserTestPrinter.php.

References $success, $total, print, skipped(), term(), and wfPercent().

Referenced by report().

◆ showFailure()

ParserTestPrinter::showFailure ( ParserTestResult  $testResult)
private

Print a failure message and provide some explanatory output about what went wrong if so configured.

Parameters
ParserTestResult$testResult
Returns
bool

Definition at line 122 of file ParserTestPrinter.php.

References ParserTestResult\getDescription(), print, quickDiff(), showTesting(), term(), and wellFormed().

Referenced by __construct(), and record().

◆ showSuccess()

ParserTestPrinter::showSuccess ( ParserTestResult  $testResult)
private

Print a happy success message.

Parameters
ParserTestResult$testResult
Returns
bool

Definition at line 109 of file ParserTestPrinter.php.

References print, and term().

Referenced by record().

◆ showTesting()

ParserTestPrinter::showTesting (   $desc)
private

Definition at line 72 of file ParserTestPrinter.php.

References print.

Referenced by showFailure(), and startTest().

◆ skipped()

ParserTestPrinter::skipped (   $test,
  $subtest 
)

Mark a test skipped.

Parameters
string$test
string$subtest

Definition at line 293 of file ParserTestPrinter.php.

References print, and term().

Referenced by reportPercentage(), and start().

◆ start()

ParserTestPrinter::start ( )

Definition at line 60 of file ParserTestPrinter.php.

References skipped().

◆ startSuite()

ParserTestPrinter::startSuite (   $path)

Show "Reading tests from ...".

Parameters
string$path

Definition at line 81 of file ParserTestPrinter.php.

References print, and term().

◆ startTest()

ParserTestPrinter::startTest (   $test)

Definition at line 66 of file ParserTestPrinter.php.

References showTesting().

◆ warning()

ParserTestPrinter::warning (   $message)

Show a warning to the user.

Parameters
string$message

Definition at line 284 of file ParserTestPrinter.php.

◆ wellFormed()

ParserTestPrinter::wellFormed (   $text)
private

Definition at line 228 of file ParserTestPrinter.php.

References $html, $parser, extractFragment(), and Sanitizer\hackDocType().

Referenced by showFailure().

Member Data Documentation

◆ $markWhitespace

ParserTestPrinter::$markWhitespace
private

Definition at line 39 of file ParserTestPrinter.php.

◆ $showDiffs

ParserTestPrinter::$showDiffs
private

Definition at line 34 of file ParserTestPrinter.php.

◆ $showFailure

ParserTestPrinter::$showFailure
private

Definition at line 36 of file ParserTestPrinter.php.

◆ $showOutput

ParserTestPrinter::$showOutput
private

Definition at line 37 of file ParserTestPrinter.php.

◆ $showProgress

ParserTestPrinter::$showProgress
private

Definition at line 35 of file ParserTestPrinter.php.

◆ $skipped

ParserTestPrinter::$skipped
private

Definition at line 32 of file ParserTestPrinter.php.

◆ $success

ParserTestPrinter::$success
private

Definition at line 31 of file ParserTestPrinter.php.

Referenced by reportPercentage().

◆ $term

ParserTestPrinter::$term
private

Definition at line 33 of file ParserTestPrinter.php.

Referenced by __construct().

◆ $total

ParserTestPrinter::$total
private

Definition at line 30 of file ParserTestPrinter.php.

Referenced by reportPercentage().

◆ $useDwdiff

ParserTestPrinter::$useDwdiff
private

Definition at line 38 of file ParserTestPrinter.php.

◆ $xmlError

ParserTestPrinter::$xmlError
private

Definition at line 40 of file ParserTestPrinter.php.


The documentation for this class was generated from the following file: