2 // ignore-emscripten no processes
3 // ignore-sgx no processes
4 // ignore-vxworks no 'env'
5 // ignore-fuchsia no 'env'
7 use std::process::Command;
10 #[cfg(all(unix, not(target_os="android")))]
11 pub fn env_cmd() -> Command {
14 #[cfg(target_os="android")]
15 pub fn env_cmd() -> Command {
16 let mut cmd = Command::new("/system/bin/sh");
17 cmd.arg("-c").arg("set");
22 pub fn env_cmd() -> Command {
23 let mut cmd = Command::new("cmd");
24 cmd.arg("/c").arg("set");
29 // save original environment
30 let old_env = env::var_os("RUN_TEST_NEW_ENV");
32 env::set_var("RUN_TEST_NEW_ENV", "123");
34 let mut cmd = env_cmd();
35 cmd.env_remove("RUN_TEST_NEW_ENV");
37 // restore original environment
39 None => env::remove_var("RUN_TEST_NEW_ENV"),
40 Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
43 let result = cmd.output().unwrap();
44 let output = String::from_utf8_lossy(&result.stdout);
46 assert!(!output.contains("RUN_TEST_NEW_ENV"),
47 "found RUN_TEST_NEW_ENV inside of:\n\n{}", output);