Introduce exec_compiled_test_general

This will allow the `run-coverage` mode to easily set environment variable
`LLVM_PROFILE_FILE`, and to prevent the executable from being deleted after a
successful run.
This commit is contained in:
Zalathar 2023-06-12 18:07:04 +10:00
parent 5b51d9cadb
commit a32cdee466

View File

@ -1598,6 +1598,14 @@ impl<'test> TestCx<'test> {
}
fn exec_compiled_test(&self) -> ProcRes {
self.exec_compiled_test_general(&[], true)
}
fn exec_compiled_test_general(
&self,
env_extra: &[(&str, &str)],
delete_after_success: bool,
) -> ProcRes {
let prepare_env = |cmd: &mut Command| {
for key in &self.props.unset_exec_env {
cmd.env_remove(key);
@ -1606,6 +1614,9 @@ impl<'test> TestCx<'test> {
for (key, val) in &self.props.exec_env {
cmd.env(key, val);
}
for (key, val) in env_extra {
cmd.env(key, val);
}
};
let proc_res = match &*self.config.target {
@ -1684,7 +1695,7 @@ impl<'test> TestCx<'test> {
}
};
if proc_res.status.success() {
if delete_after_success && proc_res.status.success() {
// delete the executable after running it to save space.
// it is ok if the deletion failed.
let _ = fs::remove_file(self.make_exe_name());