Fixes:
* give the new feature its own feature tag * correct a lifetime problem in the test * use .output() instead of .spawn() in the test so that output is actually collected * correct the same error in the test whose skeleton I cribbed
This commit is contained in:
parent
55a6fdb7fd
commit
c74efddc89
3 changed files with 6 additions and 8 deletions
|
@ -399,7 +399,7 @@ impl Command {
|
||||||
/// .spawn()
|
/// .spawn()
|
||||||
/// .expect("printenv failed to start");
|
/// .expect("printenv failed to start");
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "process", since = "1.16.0")]
|
#[stable(feature = "command_envs", since = "1.16.0")]
|
||||||
pub fn envs<K, V>(&mut self, vars: &[(K, V)]) -> &mut Command
|
pub fn envs<K, V>(&mut self, vars: &[(K, V)]) -> &mut Command
|
||||||
where K: AsRef<OsStr>, V: AsRef<OsStr>
|
where K: AsRef<OsStr>, V: AsRef<OsStr>
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,9 +41,9 @@ fn main() {
|
||||||
let filtered_env : Vec<(String, String)> =
|
let filtered_env : Vec<(String, String)> =
|
||||||
env::vars().filter(|&(ref k, _)| k == "PATH").collect();
|
env::vars().filter(|&(ref k, _)| k == "PATH").collect();
|
||||||
|
|
||||||
let mut cmd = env_cmd()
|
let mut cmd = env_cmd();
|
||||||
.env_clear()
|
cmd.env_clear();
|
||||||
.envs(&filtered_env);
|
cmd.envs(&filtered_env);
|
||||||
|
|
||||||
// restore original environment
|
// restore original environment
|
||||||
match old_env {
|
match old_env {
|
||||||
|
@ -51,8 +51,7 @@ fn main() {
|
||||||
Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
|
Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
|
||||||
}
|
}
|
||||||
|
|
||||||
let prog = cmd.spawn().unwrap();
|
let result = cmd.output().unwrap();
|
||||||
let result = prog.wait_with_output().unwrap();
|
|
||||||
let output = String::from_utf8_lossy(&result.stdout);
|
let output = String::from_utf8_lossy(&result.stdout);
|
||||||
|
|
||||||
assert!(!output.contains("RUN_TEST_NEW_ENV"),
|
assert!(!output.contains("RUN_TEST_NEW_ENV"),
|
||||||
|
|
|
@ -46,8 +46,7 @@ fn main() {
|
||||||
Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
|
Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
|
||||||
}
|
}
|
||||||
|
|
||||||
let prog = cmd.spawn().unwrap();
|
let result = cmd.output().unwrap();
|
||||||
let result = prog.wait_with_output().unwrap();
|
|
||||||
let output = String::from_utf8_lossy(&result.stdout);
|
let output = String::from_utf8_lossy(&result.stdout);
|
||||||
|
|
||||||
assert!(!output.contains("RUN_TEST_NEW_ENV"),
|
assert!(!output.contains("RUN_TEST_NEW_ENV"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue