about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2020-01-16 16:29:32 -0800
committerTyler Mandry <tmandry@gmail.com>2020-01-16 16:54:00 -0800
commit6246f7e1f90f1b72d5b9b530df2ee81beeb09f20 (patch)
treeb55fb84675d072e618f443187a0e962864239665 /src/test
parentecbc222855c890c3aabe4848e8d8b312debcf0ff (diff)
Don't propagate __RUST_TEST_INVOKE to subprocess
When -Z panic_abort_tests is enabled, we use an environment variable to
tell the subprocess which test to invoke. If that subprocess then
invokes another Rust test binary, chaos ensues.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/test-panic-abort.rs11
-rw-r--r--src/test/ui/test-panic-abort.run.stdout7
2 files changed, 15 insertions, 3 deletions
diff --git a/src/test/ui/test-panic-abort.rs b/src/test/ui/test-panic-abort.rs
index b0679ea1d3d..b7bf5a150ea 100644
--- a/src/test/ui/test-panic-abort.rs
+++ b/src/test/ui/test-panic-abort.rs
@@ -11,6 +11,7 @@
 #![cfg(test)]
 
 use std::io::Write;
+use std::env;
 
 #[test]
 fn it_works() {
@@ -35,3 +36,13 @@ fn it_fails() {
 fn it_exits() {
     std::process::exit(123);
 }
+
+#[test]
+fn no_residual_environment() {
+    for (key, _) in env::vars() {
+        // Look for keys like __RUST_TEST_INVOKE.
+        if key.contains("TEST_INVOKE") {
+            panic!("shouldn't have '{}' in environment", key);
+        }
+    }
+}
diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout
index 46adcfbc2eb..2f4bc32ed6a 100644
--- a/src/test/ui/test-panic-abort.run.stdout
+++ b/src/test/ui/test-panic-abort.run.stdout
@@ -1,9 +1,10 @@
 
-running 4 tests
+running 5 tests
 test it_exits ... FAILED
 test it_fails ... FAILED
 test it_panics ... ok
 test it_works ... ok
+test no_residual_environment ... ok
 
 failures:
 
@@ -17,7 +18,7 @@ testing123
 testing321
 thread 'main' panicked at 'assertion failed: `(left == right)`
   left: `2`,
- right: `5`', $DIR/test-panic-abort.rs:31:5
+ right: `5`', $DIR/test-panic-abort.rs:32:5
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 
 
@@ -25,5 +26,5 @@ failures:
     it_exits
     it_fails
 
-test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
+test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out