Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move a flaky process test out of libstd #56151

Merged
merged 1 commit into from
Nov 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1889,42 +1889,6 @@ mod tests {
cmd
}

#[test]
fn test_inherit_env() {
use env;

let result = env_cmd().output().unwrap();
let output = String::from_utf8(result.stdout).unwrap();

for (ref k, ref v) in env::vars() {
// Don't check android RANDOM variable which seems to change
// whenever the shell runs, and our `env_cmd` is indeed running a
// shell which means it'll get a different RANDOM than we probably
// have.
//
// Also skip env vars with `-` in the name on android because, well,
// I'm not sure. It appears though that the `set` command above does
// not print env vars with `-` in the name, so we just skip them
// here as we won't find them in the output. Note that most env vars
// use `_` instead of `-`, but our build system sets a few env vars
// with `-` in the name.
if cfg!(target_os = "android") &&
(*k == "RANDOM" || k.contains("-")) {
continue
}

// Windows has hidden environment variables whose names start with
// equals signs (`=`). Those do not show up in the output of the
// `set` command.
assert!((cfg!(windows) && k.starts_with("=")) ||
k.starts_with("DYLD") ||
output.contains(&format!("{}={}", *k, *v)) ||
output.contains(&format!("{}='{}'", *k, *v)),
"output doesn't contain `{}={}`\n{}",
k, v, output);
}
}

#[test]
fn test_override_env() {
use env;
Expand Down
25 changes: 25 additions & 0 deletions src/test/run-pass/inherit-env.rs
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);
}
}