File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ fn main() {
99
99
) ;
100
100
match ( test, & kind[ ..] ) {
101
101
( true , "test" ) => {
102
+ // For test binaries we call `cargo rustc --test target -- <rustc args>`
102
103
if let Err ( code) = process (
103
104
vec ! [ "--test" . to_string( ) , target. name] . into_iter ( ) . chain (
104
105
args,
@@ -109,6 +110,11 @@ fn main() {
109
110
}
110
111
}
111
112
( true , "lib" ) => {
113
+ // For libraries we call `cargo rustc -- --test <rustc args>`
114
+ // Notice now that `--test` is a rustc arg rather than a cargo arg. This tells
115
+ // rustc to build a test harness which calls all #[test] functions. We don't
116
+ // use the harness since we execute each #[test] function's MIR ourselves before
117
+ // compilation even completes, but this option is necessary to build the library.
112
118
if let Err ( code) = process (
113
119
vec ! [ "--" . to_string( ) , "--test" . to_string( ) ] . into_iter ( ) . chain (
114
120
args,
@@ -119,6 +125,7 @@ fn main() {
119
125
}
120
126
}
121
127
( false , "bin" ) => {
128
+ // For ordinary binaries we call `cargo rustc --bin target -- <rustc args>`
122
129
if let Err ( code) = process (
123
130
vec ! [ "--bin" . to_string( ) , target. name] . into_iter ( ) . chain (
124
131
args,
You can’t perform that action at this time.
0 commit comments