X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2FtestHelpers.inc;h=6d3ac2f5cbf5dce16edd8e1e68b4e2f926996d2d;hb=b4550b162d162c9c90713df19fa258cb4e78e358;hp=2f5fa9ea3f7cdbe90c45bb48b414e3a1fc785d2a;hpb=0c615d9029cb6e0d65c21f1df5a8a54e197b860a;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index 2f5fa9ea3f..6d3ac2f5cb 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -36,16 +36,26 @@ */ interface ITestRecorder { - /** Called at beginning of the parser test run */ + /** + * Called at beginning of the parser test run + */ public function start(); - /** Called after each test */ + /** + * Called after each test + * @param string $test + * @param bool $result + */ public function record( $test, $result ); - /** Called before finishing the test run */ + /** + * Called before finishing the test run + */ public function report(); - /** Called at the end of the parser test run */ + /** + * Called at the end of the parser test run + */ public function end(); } @@ -107,6 +117,7 @@ class DbTestPreviewer extends TestRecorder { /** * This should be called before the table prefix is changed + * @param TestRecorder $parent */ function __construct( $parent ) { parent::__construct( $parent ); @@ -220,6 +231,9 @@ class DbTestPreviewer extends TestRecorder { * Returns a string giving information about when a test last had a status change. * Could help to track down when regressions were introduced, as distinct from tests * which have never passed (which are more change requests than regressions). + * @param string $testname + * @param string $after + * @return string */ private function getTestStatusInfo( $testname, $after ) { // If we're looking at a test that has just been removed, then say when it first appeared. @@ -423,7 +437,7 @@ class TestFileIterator implements Iterator { $input = $this->checkSection( array( 'wikitext', 'input' ), false ); $result = $this->checkSection( array( 'html/php', 'html/*', 'html', 'result' ), false ); // some tests have "with tidy" and "without tidy" variants - $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy'), false ); + $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy' ), false ); if ( $tidy != false ) { if ( $this->nextSubTest == 0 ) { if ( $result != false ) { @@ -457,7 +471,7 @@ class TestFileIterator implements Iterator { $hooksResult = $this->delayedParserTest->unleash( $this->parserTest ); if ( !$hooksResult ) { # Some hook reported an issue. Abort. - throw new MWException( "Problem running hook" ); + throw new MWException( "Problem running requested parser hook from the test file" ); } $this->test = array( @@ -475,9 +489,11 @@ class TestFileIterator implements Iterator { function readNextTest() { # Run additional subtests of previous test - while ( $this->nextSubTest > 0 ) - if ( $this->setupCurrentTest() ) + while ( $this->nextSubTest > 0 ) { + if ( $this->setupCurrentTest() ) { return true; + } + } $this->clearSection(); # Reset hooks for the delayed test object @@ -542,7 +558,7 @@ class TestFileIterator implements Iterator { $line = trim( $line ); if ( $line ) { - $delayedParserTest->requireTransparentHook( $line ); + $this->delayedParserTest->requireTransparentHook( $line ); } } @@ -554,8 +570,9 @@ class TestFileIterator implements Iterator { if ( $this->section == 'end' ) { $this->checkSection( 'test' ); do { - if ( $this->setupCurrentTest() ) + if ( $this->setupCurrentTest() ) { return true; + } } while ( $this->nextSubTest > 0 ); # go on to next test (since this was disabled) $this->clearSection(); @@ -600,6 +617,8 @@ class TestFileIterator implements Iterator { * mentioned before closing this section * @param bool $fatal True iff an exception should be thrown if * the section is not found. + * @return bool|string + * @throws MWException */ private function checkSection( $tokens, $fatal = true ) { if ( is_null( $this->section ) ) { @@ -672,6 +691,8 @@ class DelayedParserTest { * Called whenever we actually want to run the hook. * Should be the case if we found the parserTest is not disabled * @param ParserTest|NewParserTest $parserTest + * @return bool + * @throws MWException */ public function unleash( &$parserTest ) { if ( !( $parserTest instanceof ParserTest || $parserTest instanceof NewParserTest ) ) { @@ -786,7 +807,7 @@ class TidySupport { global $wgTidyBin; $this->internalTidy = extension_loaded( 'tidy' ) && - class_exists( 'tidy' ); + class_exists( 'tidy' ) && !wfIsHHVM(); $this->externalTidy = is_executable( $wgTidyBin ) || Installer::locateExecutableInDefaultPaths( array( $wgTidyBin ) )