Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ pub fn run(ws: &Workspace,
process.args(args).cwd(config.cwd());

try!(config.shell().status("Running", process.to_string()));
Ok(process.exec().err())
Ok(process.exec_replace().err())
}
16 changes: 16 additions & 0 deletions src/cargo/util/process_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ impl ProcessBuilder {
}
}

#[cfg(unix)]
pub fn exec_replace(&self) -> Result<(), ProcessError> {
use std::os::unix::process::CommandExt;

let mut command = self.build_command();
let error = command.exec();
Err(process_error(&format!("could not execute process `{}`",
self.debug_string()),
Some(Box::new(error)), None, None))
}

#[cfg(windows)]
pub fn exec_replace(&self) -> Result<(), ProcessError> {
self.exec()
}

pub fn exec_with_output(&self) -> Result<Output, ProcessError> {
let mut command = self.build_command();

Expand Down
25 changes: 17 additions & 8 deletions tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,18 @@ fn exit_code() {
fn main() { std::process::exit(2); }
"#);

assert_that(p.cargo_process("run"),
execs().with_status(2)
.with_stderr("\
let mut output = String::from("\
[COMPILING] foo v0.0.1 (file[..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `target[..]`
");
if !cfg!(unix) {
output.push_str("\
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
"));
");
}
assert_that(p.cargo_process("run"),
execs().with_status(2).with_stderr(output));
}

#[test]
Expand All @@ -149,15 +153,20 @@ fn exit_code_verbose() {
fn main() { std::process::exit(2); }
"#);

assert_that(p.cargo_process("run").arg("-v"),
execs().with_status(2)
.with_stderr("\
let mut output = String::from("\
[COMPILING] foo v0.0.1 (file[..])
[RUNNING] `rustc [..]`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `target[..]`
");
if !cfg!(unix) {
output.push_str("\
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
"));
");
}

assert_that(p.cargo_process("run").arg("-v"),
execs().with_status(2).with_stderr(output));
}

#[test]
Expand Down