Introduced -re flag to handle a pattern as a regular expression, and --
flag to escape exact strings that actually happen to start with "-re".
Showing
1 changed file
with
16 additions
and
17 deletions
... | @@ -287,13 +287,19 @@ proc mu_test { args } { | ... | @@ -287,13 +287,19 @@ proc mu_test { args } { |
287 | 287 | ||
288 | set result 0 | 288 | set result 0 |
289 | for {set i 0} {$i < [llength $pattern]} {incr i} { | 289 | for {set i 0} {$i < [llength $pattern]} {incr i} { |
290 | set regexp 0 | ||
291 | switch -regexp -- "[lindex ${pattern} $i]" { | ||
292 | ^-re.*$ { set regexp 1; incr i } | ||
293 | ^-- { incr i } | ||
294 | } | ||
295 | |||
290 | regsub "\[ \t\]*$" [lindex ${pattern} $i] "" pat | 296 | regsub "\[ \t\]*$" [lindex ${pattern} $i] "" pat |
291 | verbose "i=$i, pat=$pat" 2 | 297 | verbose "i=$i, pat=$pat" 2 |
292 | 298 | ||
293 | if [regexp -- "-re.*$" $pat] { | 299 | if {$regexp} { |
294 | verbose "REGEX for $pat / [llength $pat] " 3 | 300 | verbose "REGEX for $pat / [llength $pat] " 3 |
295 | mu_expect $tmt { | 301 | mu_expect $tmt { |
296 | $pat { } | 302 | -re $pat { } |
297 | default { | 303 | default { |
298 | set result 1 | 304 | set result 1 |
299 | break | 305 | break |
... | @@ -316,21 +322,6 @@ proc mu_test { args } { | ... | @@ -316,21 +322,6 @@ proc mu_test { args } { |
316 | set result 1 | 322 | set result 1 |
317 | break | 323 | break |
318 | } | 324 | } |
319 | mu_expect $tmt { | ||
320 | -re "\[ \t]*\r\n" { } | ||
321 | default { | ||
322 | set result 1 | ||
323 | break | ||
324 | } | ||
325 | timeout { | ||
326 | set result -2 | ||
327 | break | ||
328 | } | ||
329 | eof { | ||
330 | set result -3 | ||
331 | break | ||
332 | } | ||
333 | } | ||
334 | } | 325 | } |
335 | default { | 326 | default { |
336 | set result 1 | 327 | set result 1 |
... | @@ -346,6 +337,14 @@ proc mu_test { args } { | ... | @@ -346,6 +337,14 @@ proc mu_test { args } { |
346 | } | 337 | } |
347 | } | 338 | } |
348 | } | 339 | } |
340 | if {$result == 0} { | ||
341 | mu_expect $tmt { | ||
342 | -re "\[ \t]*\r\n" { } | ||
343 | default { set result 1 } | ||
344 | timeout { set result -2 } | ||
345 | eof { set result -3 } | ||
346 | } | ||
347 | } | ||
349 | } | 348 | } |
350 | return $result | 349 | return $result |
351 | } | 350 | } | ... | ... |
-
Please register or sign in to post a comment