forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#56151 - alexcrichton:move-out-flaky-test, r…
…=nagisa 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.
- Loading branch information
Showing
2 changed files
with
25 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
|