File tree 4 files changed +13
-4
lines changed
4 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -2493,6 +2493,7 @@ dependencies = [
2493
2493
name = " miropt-test-tools"
2494
2494
version = " 0.1.0"
2495
2495
dependencies = [
2496
+ " lazy_static" ,
2496
2497
" regex" ,
2497
2498
]
2498
2499
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ edition = "2021"
5
5
6
6
[dependencies ]
7
7
regex = " 1.0"
8
+ lazy_static = " 1"
Original file line number Diff line number Diff line change 1
1
use std:: fs;
2
2
use std:: path:: Path ;
3
3
4
+ use regex:: Regex ;
5
+
4
6
pub struct MiroptTestFile {
5
7
pub expected_file : std:: path:: PathBuf ,
6
8
pub from_file : String ,
@@ -98,8 +100,11 @@ pub fn files_for_miropt_test(
98
100
from_file = format ! ( "{}.{}.mir" , test_name, first_pass) ;
99
101
to_file = Some ( second_file) ;
100
102
} 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
103
108
. captures_iter ( test_name)
104
109
. next ( )
105
110
. 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 {
127
127
// Matches test annotations like `//~ ERROR text`.
128
128
// This mirrors the regex in src/tools/compiletest/src/runtest.rs, please
129
129
// 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) )
132
134
}
133
135
134
136
/// 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