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/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&str]) -> Cli
let cargo_exe = config.cargo_exe()?;
let err = match util::process(&command)
.env(cargo::CARGO_ENV, cargo_exe)
.args(&args[1..])
.args(args)
.exec_replace()
{
Ok(()) => return Ok(()),
Expand Down
51 changes: 46 additions & 5 deletions tests/testsuite/cargo_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cargo;
use cargotest::cargo_process;
use cargotest::support::paths::{self, CargoPathExt};
use cargotest::support::registry::Package;
use cargotest::support::{basic_bin_manifest, execs, project, Project};
use cargotest::support::{basic_bin_manifest, cargo_exe, execs, project, Project};
use hamcrest::{assert_that, existing_file};

#[cfg_attr(windows, allow(dead_code))]
Expand Down Expand Up @@ -88,8 +88,6 @@ fn list_command_looks_at_path() {
#[cfg(unix)]
#[test]
fn list_command_resolves_symlinks() {
use cargotest::support::cargo_exe;

let proj = project("list-non-overlapping").build();
let proj = fake_file(
proj,
Expand Down Expand Up @@ -227,8 +225,6 @@ fn override_cargo_home() {

#[test]
fn cargo_subcommand_env() {
use cargotest::support::cargo_exe;

let src = format!(
r#"
use std::env;
Expand Down Expand Up @@ -262,6 +258,51 @@ fn cargo_subcommand_env() {
);
}

#[test]
fn cargo_subcommand_args() {
let p = project("cargo-foo")
.file(
"Cargo.toml",
r#"
[package]
name = "cargo-foo"
version = "0.0.1"
authors = []
"#,
)
.file(
"src/main.rs",
r#"
fn main() {
let args: Vec<_> = ::std::env::args().collect();
println!("{:?}", args);
}
"#,
)
.build();

assert_that(p.cargo("build"), execs().with_status(0));
let cargo_foo_bin = p.bin("cargo-foo");
assert_that(&cargo_foo_bin, existing_file());

let mut path = path();
path.push(p.target_debug_dir());
let path = env::join_paths(path.iter()).unwrap();

assert_that(
cargo_process()
.env("PATH", &path)
.arg("foo")
.arg("bar")
.arg("-v")
.arg("--help"),
execs().with_status(0).with_stdout(format!(
r#"[{:?}, "foo", "bar", "-v", "--help"]"#,
cargo_foo_bin
)),
);
}

#[test]
fn cargo_help() {
assert_that(cargo_process(), execs().with_status(0));
Expand Down