about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-11-21 21:56:23 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-11-21 21:56:23 -0800
commitd1cd4e8d0d383842acfe2d6ea75eed1e0c0909ac (patch)
treef3e77bc5d90d0b32714706b7a9a3b3c7ac60d3ab /src/test
parent0b9f19dff1347e29bf4362ab5a8fab84b43023b5 (diff)
downloadrust-d1cd4e8d0d383842acfe2d6ea75eed1e0c0909ac.tar.gz
rust-d1cd4e8d0d383842acfe2d6ea75eed1e0c0909ac.zip
Move a flaky process test out of libstd
This test ensures that everything in `env::vars()` is inherited but
that's not actually true because other tests may add env vars after we
spawn the process, causing the test to be flaky! This commit moves the
test to a run-pass test where it can execute in isolation.

Along the way this removes a lot of the platform specificity of the
test, using iteslf to print the environment instead of a foreign process.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/inherit-env.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/run-pass/inherit-env.rs b/src/test/run-pass/inherit-env.rs
new file mode 100644
index 00000000000..856d3a5f72d
--- /dev/null
+++ b/src/test/run-pass/inherit-env.rs
@@ -0,0 +1,25 @@
+// ignore-emscripten
+// ignore-wasm32
+
+use std::env;
+use std::process::Command;
+
+fn main() {
+    if env::args().nth(1).map(|s| s == "print").unwrap_or(false) {
+        for (k, v) in env::vars() {
+            println!("{}={}", k, v);
+        }
+        return
+    }
+
+    let me = env::current_exe().unwrap();
+    let result = Command::new(me).arg("print").output().unwrap();
+    let output = String::from_utf8(result.stdout).unwrap();
+
+    for (k, v) in env::vars() {
+        assert!(output.contains(&format!("{}={}", k, v)),
+                "output doesn't contain `{}={}`\n{}",
+                k, v, output);
+    }
+}
+