Skip to content

Commit

Permalink
Introduce exec_compiled_test_general
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Zalathar committed Jun 28, 2023
1 parent 5b51d9c commit a32cdee
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit a32cdee

Please sign in to comment.