@@ -10,7 +10,7 @@ use comments::ErrorMatch;
1010use regex:: Regex ;
1111use rustc_stderr:: { Level , Message } ;
1212
13- use crate :: comments:: Comments ;
13+ use crate :: comments:: { Comments , Condition } ;
1414
1515mod comments;
1616mod rustc_stderr;
@@ -103,7 +103,7 @@ pub fn run_tests(config: Config) {
103103 }
104104 let comments = Comments :: parse_file ( & path) ;
105105 // Ignore file if only/ignore rules do (not) apply
106- if ignore_file ( & comments, & target) {
106+ if ! test_file_conditions ( & comments, & target) {
107107 ignored. fetch_add ( 1 , Ordering :: Relaxed ) ;
108108 eprintln ! (
109109 "{} ... {}" ,
@@ -509,42 +509,36 @@ fn check_output(
509509
510510fn output_path ( path : & Path , comments : & Comments , kind : String , target : & str ) -> PathBuf {
511511 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) ) ) ;
513513 }
514514 path. with_extension ( kind)
515515}
516516
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) ,
525521 }
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 ;
534528 }
535- false
529+ comments . only . iter ( ) . all ( |c| test_condition ( c , target ) )
536530}
537531
538532// Taken 1:1 from compiletest-rs
539- fn get_pointer_width ( triple : & str ) -> & ' static str {
533+ fn get_pointer_width ( triple : & str ) -> u8 {
540534 if ( triple. contains ( "64" ) && !triple. ends_with ( "gnux32" ) && !triple. ends_with ( "gnu_ilp32" ) )
541535 || triple. starts_with ( "s390x" )
542536 {
543- "64bit"
537+ 64
544538 } else if triple. starts_with ( "avr" ) {
545- "16bit"
539+ 16
546540 } else {
547- "32bit"
541+ 32
548542 }
549543}
550544
0 commit comments