@@ -42,7 +42,7 @@ fn get_runners() -> Runners {
42
42
) ;
43
43
runners. insert ( "--extended-regex-tests" , ( "Run extended regex tests" , extended_regex_tests) ) ;
44
44
runners. insert ( "--mini-tests" , ( "Run mini tests" , mini_tests) ) ;
45
-
45
+ runners . insert ( "--cargo-tests" , ( "Run cargo tests" , cargo_tests ) ) ;
46
46
runners
47
47
}
48
48
@@ -88,6 +88,8 @@ struct TestArg {
88
88
use_system_gcc : bool ,
89
89
runners : Vec < String > ,
90
90
flags : Vec < String > ,
91
+ /// Additonal arguments, to be passed to commands like `cargo test`.
92
+ test_args : Vec < String > ,
91
93
nb_parts : Option < usize > ,
92
94
current_part : Option < usize > ,
93
95
sysroot_panic_abort : bool ,
@@ -144,6 +146,7 @@ impl TestArg {
144
146
show_usage ( ) ;
145
147
return Ok ( None ) ;
146
148
}
149
+ "--" => test_arg. test_args . extend ( & mut args) ,
147
150
x if runners. contains_key ( x)
148
151
&& !test_arg. runners . iter ( ) . any ( |runner| runner == x) =>
149
152
{
@@ -203,6 +206,21 @@ fn clean(_env: &Env, args: &TestArg) -> Result<(), String> {
203
206
create_dir ( & path)
204
207
}
205
208
209
+ fn cargo_tests ( test_env : & Env , test_args : & TestArg ) -> Result < ( ) , String > {
210
+ // First, we call `mini_tests` to build minicore for us. This ensures we are testing with a working `minicore`,
211
+ // and that any changes we have made affect `minicore`(since it would get rebuilt).
212
+ mini_tests ( test_env, test_args) ?;
213
+ // Then, we copy the env vars from `test_env`
214
+ // We don't want to pass things like `RUSTFLAGS`, since they contain the -Zcodegen-backend flag.
215
+ // That would force `cg_gcc` to *rebuild itself* and only then run tests, which is undesirable.
216
+ let mut env = test_env. clone ( ) ;
217
+ env. remove ( "RUSTFLAGS" ) ;
218
+ // Pass all the default args + the user-specified ones.
219
+ let mut args: Vec < & dyn AsRef < OsStr > > = vec ! [ & "cargo" , & "test" ] ;
220
+ args. extend ( test_args. test_args . iter ( ) . map ( |s| s as & dyn AsRef < OsStr > ) ) ;
221
+ run_command_with_output_and_env ( & args, None , Some ( & env) ) ?;
222
+ Ok ( ( ) )
223
+ }
206
224
fn mini_tests ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
207
225
// FIXME: create a function "display_if_not_quiet" or something along the line.
208
226
println ! ( "[BUILD] mini_core" ) ;
@@ -1218,6 +1236,7 @@ fn run_all(env: &Env, args: &TestArg) -> Result<(), String> {
1218
1236
test_libcore ( env, args) ?;
1219
1237
extended_sysroot_tests ( env, args) ?;
1220
1238
test_rustc ( env, args) ?;
1239
+ cargo_tests ( env, args) ?;
1221
1240
Ok ( ( ) )
1222
1241
}
1223
1242
0 commit comments