@@ -37,7 +37,7 @@ impl Run for TestCommand {
37
37
TestType :: FileCheck => {
38
38
cprint ! ( "File checking {}..." , testcase. name) ;
39
39
testcase. build ( manifest) ;
40
- filechecker. run ( & testcase. source , & testcase. output ) ;
40
+ filechecker. run ( & testcase. source , & testcase. output_file ) ;
41
41
}
42
42
TestType :: Compile => {
43
43
cprint ! ( "Compiling {}..." , testcase. name) ;
@@ -57,35 +57,31 @@ impl TestCommand {
57
57
pub fn collect_testcases ( & self , manifest : & Manifest ) -> Vec < TestCase > {
58
58
let mut result = vec ! [ ] ;
59
59
60
+ // Test auxiliary (should compile first)
61
+ for case in glob ( "tests/auxiliary/*.rs" ) . unwrap ( ) {
62
+ let case = case. unwrap ( ) ;
63
+ let filename = case. file_stem ( ) . unwrap ( ) ;
64
+ let name = format ! ( "auxiliary/{}" , filename. to_string_lossy( ) ) ;
65
+ let output_file = manifest. out_dir . join ( filename) ;
66
+ result. push ( TestCase { name, source : case, output_file, test : TestType :: CompileLib } )
67
+ }
68
+
60
69
// Examples
61
- for case in glob ( "example /*.rs" ) . unwrap ( ) {
70
+ for case in glob ( "examples /*.rs" ) . unwrap ( ) {
62
71
let case = case. unwrap ( ) ;
63
72
let filename = case. file_stem ( ) . unwrap ( ) ;
64
- if filename == "mini_core" {
65
- // First compile mini_core
66
- result. insert (
67
- 0 ,
68
- TestCase {
69
- name : "mini_core" . into ( ) ,
70
- source : case. clone ( ) ,
71
- output : manifest. out_dir . join ( Path :: new ( filename) ) ,
72
- test : TestType :: CompileLib ,
73
- } ,
74
- ) ;
75
- continue ;
76
- }
77
- let name = format ! ( "example/{}" , filename. to_string_lossy( ) ) ;
78
- let output = manifest. out_dir . join ( "example" ) . join ( filename) ;
79
- result. push ( TestCase { name, source : case, output, test : TestType :: Compile } )
73
+ let name = format ! ( "examples/{}" , filename. to_string_lossy( ) ) ;
74
+ let output_file = manifest. out_dir . join ( "examples" ) . join ( filename) ;
75
+ result. push ( TestCase { name, source : case, output_file, test : TestType :: Compile } )
80
76
}
81
77
82
78
// Codegen tests
83
79
for case in glob ( "tests/codegen/*.rs" ) . unwrap ( ) {
84
80
let case = case. unwrap ( ) ;
85
81
let filename = case. file_stem ( ) . unwrap ( ) ;
86
82
let name = format ! ( "codegen/{}" , filename. to_string_lossy( ) ) ;
87
- let output = manifest. out_dir . join ( "tests/codegen" ) . join ( filename) ;
88
- result. push ( TestCase { name, source : case, output , test : TestType :: FileCheck } )
83
+ let output_file = manifest. out_dir . join ( "tests/codegen" ) . join ( filename) ;
84
+ result. push ( TestCase { name, source : case, output_file , test : TestType :: FileCheck } )
89
85
}
90
86
91
87
result
@@ -102,33 +98,35 @@ pub enum TestType {
102
98
pub struct TestCase {
103
99
pub name : String ,
104
100
pub source : PathBuf ,
105
- pub output : PathBuf ,
101
+ pub output_file : PathBuf ,
106
102
pub test : TestType ,
107
103
}
108
104
109
105
impl TestCase {
110
106
pub fn build ( & self , manifest : & Manifest ) {
111
- std:: fs:: create_dir_all ( self . output . parent ( ) . unwrap ( ) ) . unwrap ( ) ;
107
+ let output_dir = self . output_file . parent ( ) . unwrap ( ) ;
108
+ std:: fs:: create_dir_all ( output_dir) . unwrap ( ) ;
112
109
let mut command = manifest. rustc ( ) ;
113
110
command
114
111
. args ( [ "--crate-type" , "bin" ] )
115
112
. arg ( "-O" )
116
113
. arg ( & self . source )
117
114
. arg ( "-o" )
118
- . arg ( & self . output ) ;
115
+ . arg ( & self . output_file ) ;
119
116
log:: debug!( "running {:?}" , command) ;
120
117
command. status ( ) . unwrap ( ) ;
121
118
}
122
119
123
120
pub fn build_lib ( & self , manifest : & Manifest ) {
124
- std:: fs:: create_dir_all ( self . output . parent ( ) . unwrap ( ) ) . unwrap ( ) ;
121
+ let output_dir = self . output_file . parent ( ) . unwrap ( ) ;
122
+ std:: fs:: create_dir_all ( output_dir) . unwrap ( ) ;
125
123
let mut command = manifest. rustc ( ) ;
126
124
command
127
125
. args ( [ "--crate-type" , "lib" ] )
128
126
. arg ( "-O" )
129
127
. arg ( & self . source )
130
128
. arg ( "--out-dir" )
131
- . arg ( self . output . parent ( ) . unwrap ( ) ) ;
129
+ . arg ( self . output_file . parent ( ) . unwrap ( ) ) ;
132
130
log:: debug!( "running {:?}" , command) ;
133
131
command. status ( ) . unwrap ( ) ;
134
132
}
0 commit comments