@@ -35,69 +35,67 @@ pub(crate) fn generate(check: bool) {
35
35
let _ = fs:: File :: open ( parser_crate_root. join ( "src/tests.rs" ) )
36
36
. unwrap ( )
37
37
. set_modified ( SystemTime :: now ( ) ) ;
38
+ }
38
39
39
- let ok_tests = tests. ok . values ( ) . sorted_by ( |a, b| a. name . cmp ( & b. name ) ) . map ( |test| {
40
- let test_name = quote:: format_ident!( "{}" , test. name) ;
41
- let test_file = format ! ( "test_data/parser/inline/ok/{test_name}.rs" ) ;
42
- let ( test_func, args) = match & test. edition {
43
- Some ( edition) => {
44
- let edition = quote:: format_ident!( "Edition{edition}" ) ;
45
- (
46
- quote:: format_ident!( "run_and_expect_no_errors_with_edition" ) ,
47
- quote:: quote! { #test_file, crate :: Edition :: #edition} ,
48
- )
49
- }
50
- None => {
51
- ( quote:: format_ident!( "run_and_expect_no_errors" ) , quote:: quote! { #test_file} )
52
- }
53
- } ;
54
- quote:: quote! {
55
- #[ test]
56
- fn #test_name( ) {
57
- #test_func( #args) ;
58
- }
40
+ let ok_tests = tests. ok . values ( ) . sorted_by ( |a, b| a. name . cmp ( & b. name ) ) . map ( |test| {
41
+ let test_name = quote:: format_ident!( "{}" , test. name) ;
42
+ let test_file = format ! ( "test_data/parser/inline/ok/{test_name}.rs" ) ;
43
+ let ( test_func, args) = match & test. edition {
44
+ Some ( edition) => {
45
+ let edition = quote:: format_ident!( "Edition{edition}" ) ;
46
+ (
47
+ quote:: format_ident!( "run_and_expect_no_errors_with_edition" ) ,
48
+ quote:: quote! { #test_file, crate :: Edition :: #edition} ,
49
+ )
59
50
}
60
- } ) ;
61
- let err_tests = tests. err . values ( ) . sorted_by ( |a, b| a. name . cmp ( & b. name ) ) . map ( |test| {
62
- let test_name = quote:: format_ident!( "{}" , test. name) ;
63
- let test_file = format ! ( "test_data/parser/inline/err/{test_name}.rs" ) ;
64
- let ( test_func, args) = match & test. edition {
65
- Some ( edition) => {
66
- let edition = quote:: format_ident!( "Edition{edition}" ) ;
67
- (
68
- quote:: format_ident!( "run_and_expect_errors_with_edition" ) ,
69
- quote:: quote! { #test_file, crate :: Edition :: #edition} ,
70
- )
71
- }
72
- None => ( quote:: format_ident!( "run_and_expect_errors" ) , quote:: quote! { #test_file} ) ,
73
- } ;
74
- quote:: quote! {
75
- #[ test]
76
- fn #test_name( ) {
77
- #test_func( #args) ;
78
- }
79
- }
80
- } ) ;
81
-
82
- let output = quote:: quote! {
83
- mod ok {
84
- use crate :: tests:: * ;
85
- #( #ok_tests) *
51
+ None => ( quote:: format_ident!( "run_and_expect_no_errors" ) , quote:: quote! { #test_file} ) ,
52
+ } ;
53
+ quote:: quote! {
54
+ #[ test]
55
+ fn #test_name( ) {
56
+ #test_func( #args) ;
86
57
}
87
- mod err {
88
- use crate :: tests:: * ;
89
- #( #err_tests) *
58
+ }
59
+ } ) ;
60
+ let err_tests = tests. err . values ( ) . sorted_by ( |a, b| a. name . cmp ( & b. name ) ) . map ( |test| {
61
+ let test_name = quote:: format_ident!( "{}" , test. name) ;
62
+ let test_file = format ! ( "test_data/parser/inline/err/{test_name}.rs" ) ;
63
+ let ( test_func, args) = match & test. edition {
64
+ Some ( edition) => {
65
+ let edition = quote:: format_ident!( "Edition{edition}" ) ;
66
+ (
67
+ quote:: format_ident!( "run_and_expect_errors_with_edition" ) ,
68
+ quote:: quote! { #test_file, crate :: Edition :: #edition} ,
69
+ )
90
70
}
71
+ None => ( quote:: format_ident!( "run_and_expect_errors" ) , quote:: quote! { #test_file} ) ,
91
72
} ;
73
+ quote:: quote! {
74
+ #[ test]
75
+ fn #test_name( ) {
76
+ #test_func( #args) ;
77
+ }
78
+ }
79
+ } ) ;
92
80
93
- let pretty = reformat ( output. to_string ( ) ) ;
94
- ensure_file_contents (
95
- crate :: flags:: CodegenType :: ParserTests ,
96
- parser_test_data. join ( "generated/runner.rs" ) . as_ref ( ) ,
97
- & pretty,
98
- check,
99
- ) ;
100
- }
81
+ let output = quote:: quote! {
82
+ mod ok {
83
+ use crate :: tests:: * ;
84
+ #( #ok_tests) *
85
+ }
86
+ mod err {
87
+ use crate :: tests:: * ;
88
+ #( #err_tests) *
89
+ }
90
+ } ;
91
+
92
+ let pretty = reformat ( output. to_string ( ) ) ;
93
+ ensure_file_contents (
94
+ crate :: flags:: CodegenType :: ParserTests ,
95
+ parser_test_data. join ( "generated/runner.rs" ) . as_ref ( ) ,
96
+ & pretty,
97
+ check,
98
+ ) ;
101
99
}
102
100
103
101
fn install_tests ( tests : & HashMap < String , Test > , tests_dir : PathBuf , check : bool ) -> Result < bool > {
0 commit comments