]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/process-remove-from-env.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // pretty-expanded FIXME #23616
15 use std
::old_io
::Command
;
18 #[cfg(all(unix, not(target_os="android")))]
19 pub fn env_cmd() -> Command
{
22 #[cfg(target_os="android")]
23 pub fn env_cmd() -> Command
{
24 let mut cmd
= Command
::new("/system/bin/sh");
25 cmd
.arg("-c").arg("set");
30 pub fn env_cmd() -> Command
{
31 let mut cmd
= Command
::new("cmd");
32 cmd
.arg("/c").arg("set");
37 // save original environment
38 let old_env
= env
::var_os("RUN_TEST_NEW_ENV");
40 env
::set_var("RUN_TEST_NEW_ENV", "123");
42 let mut cmd
= env_cmd();
43 cmd
.env_remove("RUN_TEST_NEW_ENV");
45 // restore original environment
47 None
=> env
::remove_var("RUN_TEST_NEW_ENV"),
48 Some(val
) => env
::set_var("RUN_TEST_NEW_ENV", &val
)
51 let prog
= cmd
.spawn().unwrap();
52 let result
= prog
.wait_with_output().unwrap();
53 let output
= String
::from_utf8_lossy(&result
.output
);
55 assert
!(!output
.contains("RUN_TEST_NEW_ENV"),
56 "found RUN_TEST_NEW_ENV inside of:\n\n{}", output
);