Skip to content

Commit

Permalink
Fixes:
Browse files Browse the repository at this point in the history
 * 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
  • Loading branch information
zackw committed Jan 10, 2017
1 parent 55a6fdb commit c74efdd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/libstd/process.rs
Expand Up @@ -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>
{
Expand Down
9 changes: 4 additions & 5 deletions src/test/run-pass/process-envs.rs
Expand Up @@ -41,18 +41,17 @@ 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 {
None => env::remove_var("RUN_TEST_NEW_ENV"),
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"),
Expand Down
3 changes: 1 addition & 2 deletions src/test/run-pass/process-remove-from-env.rs
Expand Up @@ -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"),
Expand Down

0 comments on commit c74efdd

Please sign in to comment.