@@ -10,7 +10,7 @@ use std::sync::Mutex;
10
10
pub use color_eyre;
11
11
use color_eyre:: eyre:: Result ;
12
12
use colored:: * ;
13
- use parser:: ErrorMatch ;
13
+ use parser:: { ErrorMatch , Pattern } ;
14
14
use regex:: Regex ;
15
15
use rustc_stderr:: { Level , Message } ;
16
16
@@ -177,7 +177,12 @@ pub fn run_tests(config: Config) -> Result<()> {
177
177
match error {
178
178
Error :: ExitStatus ( mode, exit_status) => eprintln ! ( "{mode:?} got {exit_status}" ) ,
179
179
Error :: PatternNotFound { pattern, definition_line } => {
180
- eprintln ! ( "`{pattern}` {} in stderr output" , "not found" . red( ) ) ;
180
+ match pattern {
181
+ Pattern :: SubString ( s) =>
182
+ eprintln ! ( "substring `{s}` {} in stderr output" , "not found" . red( ) ) ,
183
+ Pattern :: Regex ( r) =>
184
+ eprintln ! ( "`/{r}/` does {} stderr output" , "not match" . red( ) ) ,
185
+ }
181
186
eprintln ! (
182
187
"expected because of pattern here: {}:{definition_line}" ,
183
188
path. display( ) . to_string( ) . bold( )
@@ -257,7 +262,7 @@ enum Error {
257
262
/// Got an invalid exit status for the given mode.
258
263
ExitStatus ( Mode , ExitStatus ) ,
259
264
PatternNotFound {
260
- pattern : String ,
265
+ pattern : Pattern ,
261
266
definition_line : usize ,
262
267
} ,
263
268
/// A ui test checking for failure does not have any failure patterns
@@ -384,22 +389,19 @@ fn check_annotations(
384
389
// in the messages.
385
390
if let Some ( i) = messages_from_unknown_file_or_line
386
391
. iter ( )
387
- . position ( |msg| msg. message . contains ( error_pattern ) )
392
+ . position ( |msg| error_pattern . matches ( & msg. message ) )
388
393
{
389
394
messages_from_unknown_file_or_line. remove ( i) ;
390
395
} else {
391
- errors. push ( Error :: PatternNotFound {
392
- pattern : error_pattern. to_string ( ) ,
393
- definition_line,
394
- } ) ;
396
+ errors. push ( Error :: PatternNotFound { pattern : error_pattern. clone ( ) , definition_line } ) ;
395
397
}
396
398
}
397
399
398
400
// The order on `Level` is such that `Error` is the highest level.
399
401
// We will ensure that *all* diagnostics of level at least `lowest_annotation_level`
400
402
// are matched.
401
403
let mut lowest_annotation_level = Level :: Error ;
402
- for & ErrorMatch { ref matched , revision : ref rev, definition_line, line, level } in
404
+ for & ErrorMatch { ref pattern , revision : ref rev, definition_line, line, level } in
403
405
& comments. error_matches
404
406
{
405
407
if let Some ( rev) = rev {
@@ -415,14 +417,14 @@ fn check_annotations(
415
417
416
418
if let Some ( msgs) = messages. get_mut ( line) {
417
419
let found =
418
- msgs. iter ( ) . position ( |msg| msg. message . contains ( matched ) && msg. level == level) ;
420
+ msgs. iter ( ) . position ( |msg| pattern . matches ( & msg. message ) && msg. level == level) ;
419
421
if let Some ( found) = found {
420
422
msgs. remove ( found) ;
421
423
continue ;
422
424
}
423
425
}
424
426
425
- errors. push ( Error :: PatternNotFound { pattern : matched . to_string ( ) , definition_line } ) ;
427
+ errors. push ( Error :: PatternNotFound { pattern : pattern . clone ( ) , definition_line } ) ;
426
428
}
427
429
428
430
let filter = |msgs : Vec < Message > | -> Vec < _ > {
0 commit comments