Index: trunk/phase3/maintenance/parserTests.php |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | */ |
27 | 27 | |
28 | 28 | /** */ |
| 29 | +$optionsWithArgs = array('regex'); |
| 30 | + |
29 | 31 | require_once( 'commandLine.inc' ); |
30 | 32 | require_once( 'languages/LanguageUtf8.php' ); |
31 | 33 | |
— | — | @@ -37,6 +39,7 @@ |
38 | 40 | * @access public |
39 | 41 | */ |
40 | 42 | function ParserTest() { |
| 43 | + global $options; |
41 | 44 | if( isset( $_SERVER['argv'] ) && in_array( '--color', $_SERVER['argv'] ) ) { |
42 | 45 | $this->color = true; |
43 | 46 | } elseif( isset( $_SERVER['argv'] ) && in_array( '--color=yes', $_SERVER['argv'] ) ) { |
— | — | @@ -55,6 +58,14 @@ |
56 | 59 | } else { |
57 | 60 | $this->showDiffs = true; |
58 | 61 | } |
| 62 | + |
| 63 | + if (isset($options['regex'])) { |
| 64 | + $this->regex = $options['regex']; |
| 65 | + } |
| 66 | + else { |
| 67 | + # Matches anything |
| 68 | + $this->regex = ''; |
| 69 | + } |
59 | 70 | } |
60 | 71 | |
61 | 72 | /** |
— | — | @@ -110,12 +121,6 @@ |
111 | 122 | continue; |
112 | 123 | } |
113 | 124 | if( $section == 'end' ) { |
114 | | - if (isset ($data['disabled'])) { |
115 | | - # disabled test |
116 | | - $data = array(); |
117 | | - $section = null; |
118 | | - continue; |
119 | | - } |
120 | 125 | if( !isset( $data['test'] ) ) { |
121 | 126 | die( "'end' without 'test' at line $n\n" ); |
122 | 127 | } |
— | — | @@ -131,6 +136,13 @@ |
132 | 137 | else { |
133 | 138 | $data['options'] = $this->chomp( $data['options'] ); |
134 | 139 | } |
| 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 | + } |
135 | 147 | if( $this->runTest( |
136 | 148 | $this->chomp( $data['test'] ), |
137 | 149 | $this->chomp( $data['input'] ), |
— | — | @@ -182,7 +194,7 @@ |
183 | 195 | $user =& new User(); |
184 | 196 | $options =& ParserOptions::newFromUser( $user ); |
185 | 197 | |
186 | | - if (preg_match('/math/i', $opts)) { |
| 198 | + if (preg_match('/\\bmath\\b/i', $opts)) { |
187 | 199 | # XXX this should probably be done by the ParserOptions |
188 | 200 | require_once('Math.php'); |
189 | 201 | |
— | — | @@ -199,10 +211,10 @@ |
200 | 212 | $parser =& new Parser(); |
201 | 213 | $title =& Title::makeTitle( NS_MAIN, $titleText ); |
202 | 214 | |
203 | | - if (preg_match('/pst/i', $opts)) { |
| 215 | + if (preg_match('/\\bpst\\b/i', $opts)) { |
204 | 216 | $out = $parser->preSaveTransform( $input, $title, $user, $options ); |
205 | 217 | } |
206 | | - else if (preg_match('/msg/i', $opts)) { |
| 218 | + else if (preg_match('/\\bmsg\\b/i', $opts)) { |
207 | 219 | $out = $parser->transformMsg( $input, $options ); |
208 | 220 | } |
209 | 221 | else { |
— | — | @@ -212,10 +224,10 @@ |
213 | 225 | $op = new OutputPage(); |
214 | 226 | $op->replaceLinkHolders($out); |
215 | 227 | |
216 | | - if (preg_match('/ill/i', $opts)) { |
| 228 | + if (preg_match('/\\bill\\b/i', $opts)) { |
217 | 229 | $out .= implode( ' ', $output->getLanguageLinks() ); |
218 | 230 | } |
219 | | - if (preg_match('/cat/i', $opts)) { |
| 231 | + if (preg_match('/\\bcat\\b/i', $opts)) { |
220 | 232 | $out .= implode( ' ', $output->getCategoryLinks() ); |
221 | 233 | } |
222 | 234 | |