@@ -23,15 +23,27 @@ pub struct TestData {
2323 mode : TestMode ,
2424}
2525
26+ #[ derive( Deserialize , Debug , Copy , Clone ) ]
27+ #[ serde( rename_all = "kebab-case" ) ]
2628pub enum TestMode {
27- ElabModule ,
28- ElabTerm ,
29+ Module ,
30+ Term ,
31+ }
32+
33+ impl TestMode {
34+ fn to_command < ' a > ( self ) -> Command < ' a > {
35+ match self {
36+ TestMode :: Module => Command :: ElabModule ,
37+ TestMode :: Term => Command :: ElabTerm ,
38+ }
39+ }
2940}
3041
3142#[ derive( Deserialize , Debug ) ]
3243#[ serde( deny_unknown_fields) ]
3344#[ serde( rename_all = "kebab-case" ) ]
3445struct Config {
46+ mode : Option < TestMode > ,
3547 #[ serde( default = "DEFAULT_IGNORE" ) ]
3648 ignore : bool ,
3749 #[ serde( default = "DEFAULT_EXIT_CODE" ) ]
@@ -134,7 +146,7 @@ fn extract_module_test(path: PathBuf) -> libtest_mimic::Test<TestData> {
134146 is_bench : false ,
135147 data : TestData {
136148 input_file : path,
137- mode : TestMode :: ElabModule ,
149+ mode : TestMode :: Module ,
138150 } ,
139151 }
140152}
@@ -147,7 +159,7 @@ fn extract_term_test(path: PathBuf) -> libtest_mimic::Test<TestData> {
147159 is_bench : false ,
148160 data : TestData {
149161 input_file : path,
150- mode : TestMode :: ElabTerm ,
162+ mode : TestMode :: Term ,
151163 } ,
152164 }
153165}
@@ -188,9 +200,9 @@ fn run_test(test: &libtest_mimic::Test<TestData>) -> libtest_mimic::Outcome {
188200 return libtest_mimic:: Outcome :: Ignored ;
189201 }
190202
191- let command = match test . data . mode {
192- TestMode :: ElabModule => Command :: ElabModule ,
193- TestMode :: ElabTerm => Command :: ElabTerm ,
203+ let command = match config . mode {
204+ Some ( mode ) => mode . to_command ( ) ,
205+ None => test . data . mode . to_command ( ) ,
194206 } ;
195207 let test_command = TestCommand :: new ( command, & config, & test. data . input_file ) ;
196208 match test_command. run ( ) {
@@ -523,7 +535,5 @@ fn make_diff(actual: &str, expected: &str) -> Option<String> {
523535}
524536
525537fn diff_line ( sign : char , line_number : usize , line_width : usize , line : & str ) -> String {
526- format ! (
527- "{line_number:>line_width$}| {sign} {line}\n "
528- )
538+ format ! ( "{line_number:>line_width$}| {sign} {line}\n " )
529539}
0 commit comments