r5480 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5479‎ | r5480 | r5481 >
Date:05:58, 25 September 2004
Author:wmahan
Status:old
Tags:
Comment:
Add a "--regex" option to limit which tests are run; replace
"!!disabled" with "!!option ... disabled"
Modified paths:
  • /trunk/phase3/maintenance/parserTests.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.php
@@ -25,6 +25,8 @@
2626 */
2727
2828 /** */
 29+$optionsWithArgs = array('regex');
 30+
2931 require_once( 'commandLine.inc' );
3032 require_once( 'languages/LanguageUtf8.php' );
3133
@@ -37,6 +39,7 @@
3840 * @access public
3941 */
4042 function ParserTest() {
 43+ global $options;
4144 if( isset( $_SERVER['argv'] ) && in_array( '--color', $_SERVER['argv'] ) ) {
4245 $this->color = true;
4346 } elseif( isset( $_SERVER['argv'] ) && in_array( '--color=yes', $_SERVER['argv'] ) ) {
@@ -55,6 +58,14 @@
5659 } else {
5760 $this->showDiffs = true;
5861 }
 62+
 63+ if (isset($options['regex'])) {
 64+ $this->regex = $options['regex'];
 65+ }
 66+ else {
 67+ # Matches anything
 68+ $this->regex = '';
 69+ }
5970 }
6071
6172 /**
@@ -110,12 +121,6 @@
111122 continue;
112123 }
113124 if( $section == 'end' ) {
114 - if (isset ($data['disabled'])) {
115 - # disabled test
116 - $data = array();
117 - $section = null;
118 - continue;
119 - }
120125 if( !isset( $data['test'] ) ) {
121126 die( "'end' without 'test' at line $n\n" );
122127 }
@@ -131,6 +136,13 @@
132137 else {
133138 $data['options'] = $this->chomp( $data['options'] );
134139 }
 140+ if (preg_match('/\\bdisabled\\b/i', $data['options'])
 141+ || !preg_match("/{$this->regex}/i", $data['test'])) {
 142+ # disabled test
 143+ $data = array();
 144+ $section = null;
 145+ continue;
 146+ }
135147 if( $this->runTest(
136148 $this->chomp( $data['test'] ),
137149 $this->chomp( $data['input'] ),
@@ -182,7 +194,7 @@
183195 $user =& new User();
184196 $options =& ParserOptions::newFromUser( $user );
185197
186 - if (preg_match('/math/i', $opts)) {
 198+ if (preg_match('/\\bmath\\b/i', $opts)) {
187199 # XXX this should probably be done by the ParserOptions
188200 require_once('Math.php');
189201
@@ -199,10 +211,10 @@
200212 $parser =& new Parser();
201213 $title =& Title::makeTitle( NS_MAIN, $titleText );
202214
203 - if (preg_match('/pst/i', $opts)) {
 215+ if (preg_match('/\\bpst\\b/i', $opts)) {
204216 $out = $parser->preSaveTransform( $input, $title, $user, $options );
205217 }
206 - else if (preg_match('/msg/i', $opts)) {
 218+ else if (preg_match('/\\bmsg\\b/i', $opts)) {
207219 $out = $parser->transformMsg( $input, $options );
208220 }
209221 else {
@@ -212,10 +224,10 @@
213225 $op = new OutputPage();
214226 $op->replaceLinkHolders($out);
215227
216 - if (preg_match('/ill/i', $opts)) {
 228+ if (preg_match('/\\bill\\b/i', $opts)) {
217229 $out .= implode( ' ', $output->getLanguageLinks() );
218230 }
219 - if (preg_match('/cat/i', $opts)) {
 231+ if (preg_match('/\\bcat\\b/i', $opts)) {
220232 $out .= implode( ' ', $output->getCategoryLinks() );
221233 }
222234

Status & tagging log