@@ -27,38 +27,76 @@ impl Run for TestCommand {
27
27
cprintln ! ( "<r,s>Test failed</r,s>: {}" , info) ;
28
28
} ) ) ;
29
29
30
+ if manifest. verbose {
31
+ cprintln ! ( "<b>[TEST]</b> preparing to run tests with manifest: {:?}" , manifest) ;
32
+ }
33
+
30
34
cprintln ! ( "<b>[TEST]</b> running cargo test" ) ;
31
35
let mut command = std:: process:: Command :: new ( "cargo" ) ;
32
36
command. args ( [ "test" , "--manifest-path" , "crates/Cargo.toml" ] ) ;
37
+ if manifest. verbose {
38
+ cprintln ! ( "<b>[TEST]</b> executing command: {:?}" , command) ;
39
+ }
33
40
log:: debug!( "running {:?}" , command) ;
34
41
assert ! ( command. status( ) . unwrap( ) . success( ) , "failed to run {:?}" , command) ;
35
42
36
43
let testcases = self . collect_testcases ( manifest) ;
37
44
cprintln ! ( "<b>[TEST]</b> found {} testcases" , testcases. len( ) ) ;
45
+ if manifest. verbose {
46
+ for case in & testcases {
47
+ cprintln ! ( "<b>[TEST]</b> found test: {} ({:?})" , case. name, case. test) ;
48
+ }
49
+ }
38
50
39
51
let filechecker = FileChecker :: new ( ) ;
40
52
for testcase in testcases {
41
53
match testcase. test {
42
54
TestType :: FileCheck => {
43
- cprint ! ( "File checking {}..." , testcase. name) ;
55
+ if manifest. verbose {
56
+ cprintln ! ( "<b>[TEST]</b> file checking <cyan>{}</cyan>" , testcase. name) ;
57
+ cprintln ! ( " source: {}" , testcase. source. display( ) ) ;
58
+ cprintln ! ( " output: {}" , testcase. output_file. display( ) ) ;
59
+ } else {
60
+ cprint ! ( "File checking {}... " , testcase. name) ;
61
+ }
44
62
testcase. build ( manifest) ;
45
63
filechecker. run ( & testcase) ;
46
64
}
47
65
TestType :: Bless => {
48
- cprint ! ( "Blessing {}..." , testcase. name) ;
66
+ if manifest. verbose {
67
+ cprintln ! ( "<b>[TEST]</b> blessing <cyan>{}</cyan>" , testcase. name) ;
68
+ cprintln ! ( " source: {}" , testcase. source. display( ) ) ;
69
+ cprintln ! ( " output: {}" , testcase. output_file. display( ) ) ;
70
+ } else {
71
+ cprint ! ( "Blessing {}... " , testcase. name) ;
72
+ }
49
73
testcase. build ( manifest) ;
50
74
bless ( self . bless , & testcase) ;
51
75
}
52
76
TestType :: Compile => {
53
- cprint ! ( "Compiling {}..." , testcase. name) ;
77
+ if manifest. verbose {
78
+ cprintln ! ( "<b>[TEST]</b> compiling <cyan>{}</cyan>" , testcase. name) ;
79
+ cprintln ! ( " source: {}" , testcase. source. display( ) ) ;
80
+ cprintln ! ( " output: {}" , testcase. output_file. display( ) ) ;
81
+ } else {
82
+ cprint ! ( "Compiling {}... " , testcase. name) ;
83
+ }
54
84
testcase. build ( manifest) ;
55
85
}
56
86
TestType :: CompileLib => {
57
- cprint ! ( "Compiling lib {}..." , testcase. name) ;
87
+ if manifest. verbose {
88
+ cprintln ! ( "<b>[TEST]</b> compiling lib <cyan>{}</cyan>" , testcase. name) ;
89
+ cprintln ! ( " source: {}" , testcase. source. display( ) ) ;
90
+ cprintln ! ( " output: {}" , testcase. output_file. display( ) ) ;
91
+ } else {
92
+ cprint ! ( "Compiling lib {}... " , testcase. name) ;
93
+ }
58
94
testcase. build_lib ( manifest) ;
59
95
}
60
96
}
61
- cprintln ! ( "<g>OK</g>" ) ;
97
+ if !manifest. verbose {
98
+ cprintln ! ( "<g>OK</g>" ) ;
99
+ }
62
100
}
63
101
}
64
102
}
@@ -116,6 +154,7 @@ impl TestCommand {
116
154
}
117
155
}
118
156
157
+ #[ derive( Debug ) ]
119
158
pub enum TestType {
120
159
/// Test an executable can be compiled
121
160
Compile ,
@@ -145,8 +184,16 @@ impl TestCase {
145
184
. arg ( & self . source )
146
185
. arg ( "-o" )
147
186
. arg ( & self . output_file ) ;
187
+ if manifest. verbose {
188
+ cprintln ! ( " command: {}" , format!( "{:?}" , command) . replace( '"' , "" ) ) ;
189
+ }
148
190
log:: debug!( "running {:?}" , command) ;
149
- command. status ( ) . unwrap ( ) ;
191
+ let status = command. status ( ) . unwrap ( ) ;
192
+ if manifest. verbose {
193
+ if status. success ( ) {
194
+ cprintln ! ( " <g>success</g>" ) ;
195
+ }
196
+ }
150
197
}
151
198
152
199
pub fn build_lib ( & self , manifest : & Manifest ) {
@@ -157,10 +204,18 @@ impl TestCase {
157
204
. args ( [ "--crate-type" , "lib" ] )
158
205
. arg ( "-O" )
159
206
. arg ( & self . source )
160
- . arg ( "--out-dir" ) // we use `--out-dir` to integrate with the default name convention
161
- . arg ( output_dir) ; // so here we ignore the filename and just use the directory
207
+ . arg ( "--out-dir" )
208
+ . arg ( output_dir) ;
209
+ if manifest. verbose {
210
+ cprintln ! ( " command: {}" , format!( "{:?}" , command) . replace( '"' , "" ) ) ;
211
+ }
162
212
log:: debug!( "running {:?}" , command) ;
163
- command. status ( ) . unwrap ( ) ;
213
+ let status = command. status ( ) . unwrap ( ) ;
214
+ if manifest. verbose {
215
+ if status. success ( ) {
216
+ cprintln ! ( " <g>success</g>" ) ;
217
+ }
218
+ }
164
219
}
165
220
166
221
/// Get the generated C file f
0 commit comments