* 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:
Zack Weinberg 2017-01-10 13:00:07 -05:00
parent 55a6fdb7fd
commit c74efddc89
3 changed files with 6 additions and 8 deletions

View file

@ -399,7 +399,7 @@ impl Command {
/// .spawn()
/// .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
where K: AsRef<OsStr>, V: AsRef<OsStr>
{

View file

@ -41,9 +41,9 @@ fn main() {
let filtered_env : Vec<(String, String)> =
env::vars().filter(|&(ref k, _)| k == "PATH").collect();
let mut cmd = env_cmd()
.env_clear()
.envs(&filtered_env);
let mut cmd = env_cmd();
cmd.env_clear();
cmd.envs(&filtered_env);
// restore original environment
match old_env {
@ -51,8 +51,7 @@ fn main() {
Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
}
let prog = cmd.spawn().unwrap();
let result = prog.wait_with_output().unwrap();
let result = cmd.output().unwrap();
let output = String::from_utf8_lossy(&result.stdout);
assert!(!output.contains("RUN_TEST_NEW_ENV"),

View file

@ -46,8 +46,7 @@ fn main() {
Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val)
}
let prog = cmd.spawn().unwrap();
let result = prog.wait_with_output().unwrap();
let result = cmd.output().unwrap();
let output = String::from_utf8_lossy(&result.stdout);
assert!(!output.contains("RUN_TEST_NEW_ENV"),