From a32cdee4662852eeeba64eebb35516421d330d5b Mon Sep 17 00:00:00 2001 From: Zalathar Date: Mon, 12 Jun 2023 18:07:04 +1000 Subject: [PATCH] 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. --- src/tools/compiletest/src/runtest.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4439d60ac06cb..c7093c9780dbb 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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());