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());