File tree Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Expand file tree Collapse file tree 4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -2493,6 +2493,7 @@ dependencies = [
24932493name = " miropt-test-tools"
24942494version = " 0.1.0"
24952495dependencies = [
2496+ " lazy_static" ,
24962497 " regex" ,
24972498]
24982499
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ edition = "2021"
55
66[dependencies ]
77regex = " 1.0"
8+ lazy_static = " 1"
Original file line number Diff line number Diff line change 11use std:: fs;
22use std:: path:: Path ;
33
4+ use regex:: Regex ;
5+
46pub struct MiroptTestFile {
57 pub expected_file : std:: path:: PathBuf ,
68 pub from_file : String ,
@@ -98,8 +100,11 @@ pub fn files_for_miropt_test(
98100 from_file = format ! ( "{}.{}.mir" , test_name, first_pass) ;
99101 to_file = Some ( second_file) ;
100102 } else {
101- let ext_re = regex:: Regex :: new ( r#"(\.(mir|dot|html))$"# ) . unwrap ( ) ;
102- let cap = ext_re
103+ lazy_static:: lazy_static! {
104+ static ref EXT_RE : Regex = Regex :: new( r#"(\.(mir|dot|html))$"# ) . unwrap( ) ;
105+ }
106+
107+ let cap = EXT_RE
103108 . captures_iter ( test_name)
104109 . next ( )
105110 . expect ( "test_name has an invalid extension" ) ;
Original file line number Diff line number Diff line change @@ -127,8 +127,10 @@ fn should_ignore(line: &str) -> bool {
127127 // Matches test annotations like `//~ ERROR text`.
128128 // This mirrors the regex in src/tools/compiletest/src/runtest.rs, please
129129 // update both if either are changed.
130- let re = Regex :: new ( "\\ s*//(\\ [.*\\ ])?~.*" ) . unwrap ( ) ;
131- re. is_match ( line) || ANNOTATIONS_TO_IGNORE . iter ( ) . any ( |a| line. contains ( a) )
130+ lazy_static:: lazy_static! {
131+ static ref ANNOTATION_RE : Regex = Regex :: new( "\\ s*//(\\ [.*\\ ])?~.*" ) . unwrap( ) ;
132+ }
133+ ANNOTATION_RE . is_match ( line) || ANNOTATIONS_TO_IGNORE . iter ( ) . any ( |a| line. contains ( a) )
132134}
133135
134136/// Returns `true` if `line` is allowed to be longer than the normal limit.
You can’t perform that action at this time.
0 commit comments