about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-06-12 18:07:04 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-06-28 11:08:09 +1000
commita32cdee4662852eeeba64eebb35516421d330d5b (patch)
treec9f92dfa906a449b948c0a8ad6dba98503139869 /src/tools/compiletest
parent5b51d9cadb0a91e337b3a2e624e038eedcd0f529 (diff)
downloadrust-a32cdee4662852eeeba64eebb35516421d330d5b.tar.gz
rust-a32cdee4662852eeeba64eebb35516421d330d5b.zip
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.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/runtest.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 4439d60ac06..c7093c9780d 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());