From: Wil Mahan Date: Thu, 23 Sep 2004 00:30:28 +0000 (+0000) Subject: allow simple variables in expected test results; use tidy on expected result when X-Git-Tag: 1.5.0alpha1~1873 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=7186524e11afc9f3094f0553685d4d25adbb4672;p=lhc%2Fweb%2Fwiklou.git allow simple variables in expected test results; use tidy on expected result when $wgUseTidy is enabled, which makes it possible to disregard cosmetic formatting discrepancies --- diff --git a/maintenance/parserTests.php b/maintenance/parserTests.php index 3fdd3f287b..5e70ca051b 100644 --- a/maintenance/parserTests.php +++ b/maintenance/parserTests.php @@ -46,7 +46,7 @@ class ParserTest { if( $this->runTest( rtrim( $data['test'] ), rtrim( $data['input'] ), - rtrim( $data['result'] ) ) ) { + $this->resultTransform(rtrim( $data['result'] ) ) ) ) { $success++; } $total++; @@ -67,6 +67,19 @@ class ParserTest { } } + /** + * Substitute simple variables to allow for slightly more + * sophisticated tests. + * @access private + */ + function resultTransform($text) { + $rep = array ( + '__SCRIPT__' => $GLOBALS['wgScript'] + ); + $text = str_replace(array_keys($rep), array_values($rep), $text); + return $text; + } + /** * @param string $input Wikitext to try rendering * @param string $result Result to output @@ -88,8 +101,17 @@ class ParserTest { $op = new OutputPage(); $op->replaceLinkHolders($html); + + global $wgUseTidy; + if ($wgUseTidy) { + # Using Parser here is probably theoretically + # wrong, because we shouldn't use Parser to + # validate itself, but this should be safe + # in practice. + $result = Parser::tidy($result); + } - if( $result == rtrim( $html ) ) { + if( rtrim($result) === rtrim($html) ) { return $this->showSuccess( $desc ); } else { return $this->showFailure( $desc, $result, $html );