Skip to content

Commit 0a872ff

Browse files
committed
modifed y.sh to allow for running cargo tests.
1 parent cfe88fa commit 0a872ff

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

build_system/src/test.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn get_runners() -> Runners {
4242
);
4343
runners.insert("--extended-regex-tests", ("Run extended regex tests", extended_regex_tests));
4444
runners.insert("--mini-tests", ("Run mini tests", mini_tests));
45-
45+
runners.insert("--cargo-tests", ("Run cargo tests", cargo_tests));
4646
runners
4747
}
4848

@@ -203,6 +203,19 @@ fn clean(_env: &Env, args: &TestArg) -> Result<(), String> {
203203
create_dir(&path)
204204
}
205205

206+
fn cargo_tests(test_env: &Env, args: &TestArg) -> Result<(), String> {
207+
// First, we call `mini_tests` to build minicore for us. This ensures we are testing with a working `minicore`,
208+
// and that any changes we have made affect `minicore`(since it would get rebuilt).
209+
mini_tests(test_env, args)?;
210+
// Then, we copy the env vars from `test_env`
211+
// We don't want to pass things like `RUSTFLAGS`, since they contain the -Zcodegen-backend flag.
212+
// That would force `cg_gcc` to *rebuild itself* and only then run tests, which is undesirable.
213+
let mut env = test_env.clone();
214+
env.remove("RUSTFLAGS");
215+
// FIXME: maybe we could allow for only a select test to be run?
216+
run_command_with_output_and_env(&[&"cargo", &"test"], None, Some(&env))?;
217+
Ok(())
218+
}
206219
fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> {
207220
// FIXME: create a function "display_if_not_quiet" or something along the line.
208221
println!("[BUILD] mini_core");
@@ -1218,6 +1231,7 @@ fn run_all(env: &Env, args: &TestArg) -> Result<(), String> {
12181231
test_libcore(env, args)?;
12191232
extended_sysroot_tests(env, args)?;
12201233
test_rustc(env, args)?;
1234+
cargo_tests(env, args)?;
12211235
Ok(())
12221236
}
12231237

0 commit comments

Comments
 (0)