@@ -18,23 +18,21 @@ use crate::{
18
18
util:: list_rust_files,
19
19
} ;
20
20
21
- const PARSER_CRATE_ROOT : & str = "crates/parser" ;
22
- const PARSER_TEST_DATA : & str = "crates/parser/test_data" ;
23
- const PARSER_TEST_DATA_INLINE : & str = "crates/parser/test_data/parser/inline" ;
24
-
25
21
pub ( crate ) fn generate ( check : bool ) {
26
- let tests = tests_from_dir (
27
- & project_root ( ) . join ( Path :: new ( & format ! ( "{PARSER_CRATE_ROOT}/src/grammar" ) ) ) ,
28
- ) ;
22
+ let parser_crate_root = project_root ( ) . join ( "crates/parser" ) ;
23
+ let parser_test_data = parser_crate_root. join ( "test_data" ) ;
24
+ let parser_test_data_inline = parser_test_data. join ( "parser/inline" ) ;
25
+
26
+ let tests = tests_from_dir ( & parser_crate_root. join ( "src/grammar" ) ) ;
29
27
30
28
let mut some_file_was_updated = false ;
31
29
some_file_was_updated |=
32
- install_tests ( & tests. ok , & format ! ( "{PARSER_TEST_DATA_INLINE}/ ok") , check) . unwrap ( ) ;
30
+ install_tests ( & tests. ok , parser_test_data_inline . join ( " ok") , check) . unwrap ( ) ;
33
31
some_file_was_updated |=
34
- install_tests ( & tests. err , & format ! ( "{PARSER_TEST_DATA_INLINE}/ err") , check) . unwrap ( ) ;
32
+ install_tests ( & tests. err , parser_test_data_inline . join ( " err") , check) . unwrap ( ) ;
35
33
36
34
if some_file_was_updated {
37
- let _ = fs:: File :: open ( format ! ( "{PARSER_CRATE_ROOT}/ src/tests.rs") )
35
+ let _ = fs:: File :: open ( parser_crate_root . join ( " src/tests.rs") )
38
36
. unwrap ( )
39
37
. set_modified ( SystemTime :: now ( ) ) ;
40
38
@@ -95,15 +93,14 @@ pub(crate) fn generate(check: bool) {
95
93
let pretty = reformat ( output. to_string ( ) ) ;
96
94
ensure_file_contents (
97
95
crate :: flags:: CodegenType :: ParserTests ,
98
- format ! ( "{PARSER_TEST_DATA}/ generated/runner.rs") . as_ref ( ) ,
96
+ parser_test_data . join ( " generated/runner.rs") . as_ref ( ) ,
99
97
& pretty,
100
98
check,
101
99
) ;
102
100
}
103
101
}
104
102
105
- fn install_tests ( tests : & HashMap < String , Test > , into : & str , check : bool ) -> Result < bool > {
106
- let tests_dir = project_root ( ) . join ( into) ;
103
+ fn install_tests ( tests : & HashMap < String , Test > , tests_dir : PathBuf , check : bool ) -> Result < bool > {
107
104
if !tests_dir. is_dir ( ) {
108
105
fs:: create_dir_all ( & tests_dir) ?;
109
106
}
0 commit comments