@@ -115,8 +115,10 @@ pub fn run_tests(mut config: Config) -> Result<()> {
115
115
if path. is_dir ( ) {
116
116
// Enqueue everything inside this directory.
117
117
// We want it sorted, to have some control over scheduling of slow tests.
118
- let mut entries =
119
- std:: fs:: read_dir ( path) . unwrap ( ) . collect :: < Result < Vec < _ > , _ > > ( ) . unwrap ( ) ;
118
+ let mut entries = std:: fs:: read_dir ( path)
119
+ . unwrap ( )
120
+ . collect :: < Result < Vec < _ > , _ > > ( )
121
+ . unwrap ( ) ;
120
122
entries. sort_by_key ( |e| e. file_name ( ) ) ;
121
123
for entry in entries {
122
124
todo. push_back ( entry. path ( ) ) ;
@@ -178,7 +180,11 @@ pub fn run_tests(mut config: Config) -> Result<()> {
178
180
for path in & receive {
179
181
if !config. path_filter . is_empty ( ) {
180
182
let path_display = path. display ( ) . to_string ( ) ;
181
- if !config. path_filter . iter ( ) . any ( |filter| path_display. contains ( filter) ) {
183
+ if !config
184
+ . path_filter
185
+ . iter ( )
186
+ . any ( |filter| path_display. contains ( filter) )
187
+ {
182
188
filtered. fetch_add ( 1 , Ordering :: Relaxed ) ;
183
189
continue ;
184
190
}
@@ -192,8 +198,10 @@ pub fn run_tests(mut config: Config) -> Result<()> {
192
198
continue ;
193
199
}
194
200
// Run the test for all revisions
195
- for revision in
196
- comments. revisions . clone ( ) . unwrap_or_else ( || vec ! [ String :: new( ) ] )
201
+ for revision in comments
202
+ . revisions
203
+ . clone ( )
204
+ . unwrap_or_else ( || vec ! [ String :: new( ) ] )
197
205
{
198
206
let ( m, errors, stderr) =
199
207
run_test ( & path, & config, & target, & revision, & comments) ;
@@ -248,12 +256,17 @@ pub fn run_tests(mut config: Config) -> Result<()> {
248
256
for error in errors {
249
257
match error {
250
258
Error :: ExitStatus ( mode, exit_status) => eprintln ! ( "{mode:?} got {exit_status}" ) ,
251
- Error :: PatternNotFound { pattern, definition_line } => {
259
+ Error :: PatternNotFound {
260
+ pattern,
261
+ definition_line,
262
+ } => {
252
263
match pattern {
253
- Pattern :: SubString ( s) =>
254
- eprintln ! ( "substring `{s}` {} in stderr output" , "not found" . red( ) ) ,
255
- Pattern :: Regex ( r) =>
256
- eprintln ! ( "`/{r}/` does {} stderr output" , "not match" . red( ) ) ,
264
+ Pattern :: SubString ( s) => {
265
+ eprintln ! ( "substring `{s}` {} in stderr output" , "not found" . red( ) )
266
+ }
267
+ Pattern :: Regex ( r) => {
268
+ eprintln ! ( "`/{r}/` does {} stderr output" , "not match" . red( ) )
269
+ }
257
270
}
258
271
eprintln ! (
259
272
"expected because of pattern here: {}:{definition_line}" ,
@@ -263,11 +276,19 @@ pub fn run_tests(mut config: Config) -> Result<()> {
263
276
Error :: NoPatternsFound => {
264
277
eprintln ! ( "{}" , "no error patterns found in failure test" . red( ) ) ;
265
278
}
266
- Error :: PatternFoundInPassTest =>
267
- eprintln ! ( "{}" , "error pattern found in success test" . red( ) ) ,
268
- Error :: OutputDiffers { path, actual, expected } => {
279
+ Error :: PatternFoundInPassTest => {
280
+ eprintln ! ( "{}" , "error pattern found in success test" . red( ) )
281
+ }
282
+ Error :: OutputDiffers {
283
+ path,
284
+ actual,
285
+ expected,
286
+ } => {
269
287
eprintln ! ( "actual output differed from expected {}" , path. display( ) ) ;
270
- eprintln ! ( "{}" , pretty_assertions:: StrComparison :: new( expected, actual) ) ;
288
+ eprintln ! (
289
+ "{}" ,
290
+ pretty_assertions:: StrComparison :: new( expected, actual)
291
+ ) ;
271
292
eprintln ! ( )
272
293
}
273
294
Error :: ErrorsWithoutPattern { path : None , msgs } => {
@@ -279,7 +300,10 @@ pub fn run_tests(mut config: Config) -> Result<()> {
279
300
eprintln ! ( " {level:?}: {message}" )
280
301
}
281
302
}
282
- Error :: ErrorsWithoutPattern { path : Some ( ( path, line) ) , msgs } => {
303
+ Error :: ErrorsWithoutPattern {
304
+ path : Some ( ( path, line) ) ,
305
+ msgs,
306
+ } => {
283
307
eprintln ! (
284
308
"There were {} unmatched diagnostics at {}:{line}" ,
285
309
msgs. len( ) ,
@@ -457,16 +481,24 @@ fn check_annotations(
457
481
{
458
482
messages_from_unknown_file_or_line. remove ( i) ;
459
483
} else {
460
- errors. push ( Error :: PatternNotFound { pattern : error_pattern. clone ( ) , definition_line } ) ;
484
+ errors. push ( Error :: PatternNotFound {
485
+ pattern : error_pattern. clone ( ) ,
486
+ definition_line,
487
+ } ) ;
461
488
}
462
489
}
463
490
464
491
// The order on `Level` is such that `Error` is the highest level.
465
492
// We will ensure that *all* diagnostics of level at least `lowest_annotation_level`
466
493
// are matched.
467
494
let mut lowest_annotation_level = Level :: Error ;
468
- for & ErrorMatch { ref pattern, revision : ref rev, definition_line, line, level } in
469
- & comments. error_matches
495
+ for & ErrorMatch {
496
+ ref pattern,
497
+ revision : ref rev,
498
+ definition_line,
499
+ line,
500
+ level,
501
+ } in & comments. error_matches
470
502
{
471
503
if let Some ( rev) = rev {
472
504
if rev != revision {
@@ -480,22 +512,28 @@ fn check_annotations(
480
512
lowest_annotation_level = std:: cmp:: min ( lowest_annotation_level, level) ;
481
513
482
514
if let Some ( msgs) = messages. get_mut ( line) {
483
- let found =
484
- msgs. iter ( ) . position ( |msg| pattern. matches ( & msg. message ) && msg. level == level) ;
515
+ let found = msgs
516
+ . iter ( )
517
+ . position ( |msg| pattern. matches ( & msg. message ) && msg. level == level) ;
485
518
if let Some ( found) = found {
486
519
msgs. remove ( found) ;
487
520
continue ;
488
521
}
489
522
}
490
523
491
- errors. push ( Error :: PatternNotFound { pattern : pattern. clone ( ) , definition_line } ) ;
524
+ errors. push ( Error :: PatternNotFound {
525
+ pattern : pattern. clone ( ) ,
526
+ definition_line,
527
+ } ) ;
492
528
}
493
529
494
530
let filter = |msgs : Vec < Message > | -> Vec < _ > {
495
531
msgs. into_iter ( )
496
532
. filter ( |msg| {
497
533
msg. level
498
- >= comments. require_annotations_for_level . unwrap_or ( lowest_annotation_level)
534
+ >= comments
535
+ . require_annotations_for_level
536
+ . unwrap_or ( lowest_annotation_level)
499
537
} )
500
538
. collect ( )
501
539
} ;
@@ -511,12 +549,17 @@ fn check_annotations(
511
549
for ( line, msgs) in messages. into_iter ( ) . enumerate ( ) {
512
550
let msgs = filter ( msgs) ;
513
551
if !msgs. is_empty ( ) {
514
- errors
515
- . push ( Error :: ErrorsWithoutPattern { path : Some ( ( path. to_path_buf ( ) , line) ) , msgs } ) ;
552
+ errors. push ( Error :: ErrorsWithoutPattern {
553
+ path : Some ( ( path. to_path_buf ( ) , line) ) ,
554
+ msgs,
555
+ } ) ;
516
556
}
517
557
}
518
558
519
- match ( config. mode , comments. error_pattern . is_some ( ) || !comments. error_matches . is_empty ( ) ) {
559
+ match (
560
+ config. mode ,
561
+ comments. error_pattern . is_some ( ) || !comments. error_matches . is_empty ( ) ,
562
+ ) {
520
563
( Mode :: Pass , true ) | ( Mode :: Panic , true ) => errors. push ( Error :: PatternFoundInPassTest ) ,
521
564
( Mode :: Fail , false ) => errors. push ( Error :: NoPatternsFound ) ,
522
565
_ => { }
@@ -536,12 +579,13 @@ fn check_output(
536
579
let output = normalize ( path, output, filters, comments) ;
537
580
let path = output_path ( path, comments, kind, target) ;
538
581
match config. output_conflict_handling {
539
- OutputConflictHandling :: Bless =>
582
+ OutputConflictHandling :: Bless => {
540
583
if output. is_empty ( ) {
541
584
let _ = std:: fs:: remove_file ( path) ;
542
585
} else {
543
586
std:: fs:: write ( path, & output) . unwrap ( ) ;
544
- } ,
587
+ }
588
+ }
545
589
OutputConflictHandling :: Error => {
546
590
let expected_output = std:: fs:: read_to_string ( & path) . unwrap_or_default ( ) ;
547
591
if output != expected_output {
@@ -573,10 +617,17 @@ fn test_condition(condition: &Condition, target: &str, config: &Config) -> bool
573
617
574
618
/// Returns whether according to the in-file conditions, this file should be run.
575
619
fn test_file_conditions ( comments : & Comments , target : & str , config : & Config ) -> bool {
576
- if comments. ignore . iter ( ) . any ( |c| test_condition ( c, target, config) ) {
620
+ if comments
621
+ . ignore
622
+ . iter ( )
623
+ . any ( |c| test_condition ( c, target, config) )
624
+ {
577
625
return false ;
578
626
}
579
- comments. only . iter ( ) . all ( |c| test_condition ( c, target, config) )
627
+ comments
628
+ . only
629
+ . iter ( )
630
+ . all ( |c| test_condition ( c, target, config) )
580
631
}
581
632
582
633
// Taken 1:1 from compiletest-rs
0 commit comments