@@ -10,7 +10,7 @@ use comments::ErrorMatch;
10
10
use regex:: Regex ;
11
11
use rustc_stderr:: { Level , Message } ;
12
12
13
- use crate :: comments:: Comments ;
13
+ use crate :: comments:: { Comments , Condition } ;
14
14
15
15
mod comments;
16
16
mod rustc_stderr;
@@ -103,7 +103,7 @@ pub fn run_tests(config: Config) {
103
103
}
104
104
let comments = Comments :: parse_file ( & path) ;
105
105
// Ignore file if only/ignore rules do (not) apply
106
- if ignore_file ( & comments, & target) {
106
+ if ! test_file_conditions ( & comments, & target) {
107
107
ignored. fetch_add ( 1 , Ordering :: Relaxed ) ;
108
108
eprintln ! (
109
109
"{} ... {}" ,
@@ -509,42 +509,36 @@ fn check_output(
509
509
510
510
fn output_path ( path : & Path , comments : & Comments , kind : String , target : & str ) -> PathBuf {
511
511
if comments. stderr_per_bitwidth {
512
- return path. with_extension ( format ! ( "{}.{kind}" , get_pointer_width( target) ) ) ;
512
+ return path. with_extension ( format ! ( "{}bit .{kind}" , get_pointer_width( target) ) ) ;
513
513
}
514
514
path. with_extension ( kind)
515
515
}
516
516
517
- fn ignore_file ( comments : & Comments , target : & str ) -> bool {
518
- for s in & comments. ignore {
519
- if target. contains ( s) {
520
- return true ;
521
- }
522
- if get_pointer_width ( target) == s {
523
- return true ;
524
- }
517
+ fn test_condition ( condition : & Condition , target : & str ) -> bool {
518
+ match condition {
519
+ Condition :: Bitwidth ( bits) => get_pointer_width ( target) == * bits,
520
+ Condition :: Target ( t) => target. contains ( t) ,
525
521
}
526
- for s in & comments. only {
527
- if !target. contains ( s) {
528
- return true ;
529
- }
530
- /* FIXME(https://github.com/rust-lang/miri/issues/2206)
531
- if get_pointer_width(target) != s {
532
- return true;
533
- } */
522
+ }
523
+
524
+ /// Returns whether according to the in-file conditions, this file should be run.
525
+ fn test_file_conditions ( comments : & Comments , target : & str ) -> bool {
526
+ if comments. ignore . iter ( ) . any ( |c| test_condition ( c, target) ) {
527
+ return false ;
534
528
}
535
- false
529
+ comments . only . iter ( ) . all ( |c| test_condition ( c , target ) )
536
530
}
537
531
538
532
// Taken 1:1 from compiletest-rs
539
- fn get_pointer_width ( triple : & str ) -> & ' static str {
533
+ fn get_pointer_width ( triple : & str ) -> u8 {
540
534
if ( triple. contains ( "64" ) && !triple. ends_with ( "gnux32" ) && !triple. ends_with ( "gnu_ilp32" ) )
541
535
|| triple. starts_with ( "s390x" )
542
536
{
543
- "64bit"
537
+ 64
544
538
} else if triple. starts_with ( "avr" ) {
545
- "16bit"
539
+ 16
546
540
} else {
547
- "32bit"
541
+ 32
548
542
}
549
543
}
550
544
0 commit comments