Skip to content

Commit cf4694e

Browse files
committed
std: Change ProcessOptions struct to have an option of a ~ vector
This is a workaround for #8498
1 parent e7b5729 commit cf4694e

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn run(lib_path: &str,
4949

5050
let env = env + target_env(lib_path, prog);
5151
let mut proc = run::Process::new(prog, args, run::ProcessOptions {
52-
env: Some(env.slice(0, env.len())),
52+
env: Some(env),
5353
dir: None,
5454
in_fd: None,
5555
out_fd: None,

src/librustpkg/tests.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn mk_temp_workspace(short_name: &Path, version: &Version) -> Path {
114114
fn run_git(args: &[~str], env: Option<~[(~str, ~str)]>, cwd: &Path, err_msg: &str) {
115115
let cwd = (*cwd).clone();
116116
let mut prog = run::Process::new("git", args, run::ProcessOptions {
117-
env: env.map(|v| v.slice(0, v.len())),
117+
env: env,
118118
dir: Some(&cwd),
119119
in_fd: None,
120120
out_fd: None,
@@ -222,7 +222,7 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s
222222
assert!(os::path_is_dir(&*cwd));
223223
let cwd = (*cwd).clone();
224224
let mut prog = run::Process::new(cmd, args, run::ProcessOptions {
225-
env: env.map(|v| v.slice(0, v.len())),
225+
env: env,
226226
dir: Some(&cwd),
227227
in_fd: None,
228228
out_fd: None,
@@ -757,7 +757,9 @@ fn rust_path_test() {
757757
// use command_line_test_with_env
758758
let mut prog = run::Process::new("rustpkg",
759759
[~"install", ~"foo"],
760-
run::ProcessOptions { env: Some(&[(~"RUST_LOG",
760+
// This should actually extend the environment; then we can probably
761+
// un-ignore it
762+
run::ProcessOptions { env: Some(~[(~"RUST_LOG",
761763
~"rustpkg"),
762764
(~"RUST_PATH",
763765
dir_for_path.to_str())]),
@@ -1039,7 +1041,7 @@ fn test_extern_mod() {
10391041
~"--sysroot", test_sysroot().to_str(),
10401042
~"-o", exec_file.to_str()],
10411043
run::ProcessOptions {
1042-
env: env.map(|v| v.slice(0, v.len())),
1044+
env: env,
10431045
dir: Some(&dir),
10441046
in_fd: None,
10451047
out_fd: None,

src/libstd/run.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub struct ProcessOptions<'self> {
6868
* If this is Some(vec-of-names-and-values) then the new process will
6969
* have an environment containing the given named values only.
7070
*/
71-
env: Option<&'self [(~str, ~str)]>,
71+
env: Option<~[(~str, ~str)]>,
7272

7373
/**
7474
* If this is None then the new process will use the same initial working
@@ -171,7 +171,7 @@ impl Process {
171171
Some(fd) => (None, fd)
172172
};
173173

174-
let res = spawn_process_os(prog, args, options.env, options.dir,
174+
let res = spawn_process_os(prog, args, options.env.clone(), options.dir,
175175
in_fd, out_fd, err_fd);
176176

177177
unsafe {
@@ -444,7 +444,7 @@ struct SpawnProcessResult {
444444

445445
#[cfg(windows)]
446446
fn spawn_process_os(prog: &str, args: &[~str],
447-
env: Option<&[(~str, ~str)]>,
447+
env: Option<~[(~str, ~str)]>,
448448
dir: Option<&Path>,
449449
in_fd: c_int, out_fd: c_int, err_fd: c_int) -> SpawnProcessResult {
450450

@@ -627,7 +627,7 @@ pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
627627

628628
#[cfg(unix)]
629629
fn spawn_process_os(prog: &str, args: &[~str],
630-
env: Option<&[(~str, ~str)]>,
630+
env: Option<~[(~str, ~str)]>,
631631
dir: Option<&Path>,
632632
in_fd: c_int, out_fd: c_int, err_fd: c_int) -> SpawnProcessResult {
633633

@@ -717,7 +717,7 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
717717
}
718718

719719
#[cfg(unix)]
720-
fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
720+
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
721721
use vec;
722722

723723
// On posixy systems we can pass a char** for envp, which is a
@@ -749,7 +749,7 @@ fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
749749
}
750750

751751
#[cfg(windows)]
752-
fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
752+
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
753753
// On win32 we pass an "environment block" which is not a char**, but
754754
// rather a concatenation of null-terminated k=v\0 sequences, with a final
755755
// \0 to terminate.
@@ -1284,22 +1284,22 @@ mod tests {
12841284
}
12851285
12861286
#[cfg(unix,not(target_os="android"))]
1287-
fn run_env(env: Option<&[(~str, ~str)]>) -> run::Process {
1287+
fn run_env(env: Option<~[(~str, ~str)]>) -> run::Process {
12881288
run::Process::new("env", [], run::ProcessOptions {
12891289
env: env,
12901290
.. run::ProcessOptions::new()
12911291
})
12921292
}
12931293
#[cfg(unix,target_os="android")]
1294-
fn run_env(env: Option<&[(~str, ~str)]>) -> run::Process {
1294+
fn run_env(env: Option<~[(~str, ~str)]>) -> run::Process {
12951295
run::Process::new("/system/bin/sh", [~"-c",~"set"], run::ProcessOptions {
12961296
env: env,
12971297
.. run::ProcessOptions::new()
12981298
})
12991299
}
13001300
13011301
#[cfg(windows)]
1302-
fn run_env(env: Option<&[(~str, ~str)]>) -> run::Process {
1302+
fn run_env(env: Option<~[(~str, ~str)]>) -> run::Process {
13031303
run::Process::new("cmd", [~"/c", ~"set"], run::ProcessOptions {
13041304
env: env,
13051305
.. run::ProcessOptions::new()
@@ -1344,7 +1344,7 @@ mod tests {
13441344
let mut new_env = os::env();
13451345
new_env.push((~"RUN_TEST_NEW_ENV", ~"123"));
13461346
1347-
let mut prog = run_env(Some(new_env.slice(0, new_env.len())));
1347+
let mut prog = run_env(Some(new_env));
13481348
let output = str::from_bytes(prog.finish_with_output().output);
13491349
13501350
assert!(output.contains("RUN_TEST_NEW_ENV=123"));

0 commit comments

Comments
 (0)