.file("d2/src/main.rs", "fn main() { println!(\"d2\"); }")
.build();
- assert_that(
- p.cargo("build")
- .arg("-p")
- .arg("d1")
- .arg("-p")
- .arg("d2")
- .arg("-p")
- .arg("foo"),
- execs().with_status(0),
- );
+ assert_that(p.cargo("build -p d1 -p d2 -p foo"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(
pub fn cargo(&self, cmd: &str) -> ProcessBuilder {
let mut p = self.process(&cargo_exe());
- p.arg(cmd);
+ for arg in cmd.split_whitespace() {
+ if arg.contains('"') || arg.contains('\'') {
+ panic!("shell-style argument parsing is not supported")
+ }
+ p.arg(arg);
+ }
return p;
}
.file("d2/src/main.rs", "fn main() { println!(\"d2\"); }")
.build();
- assert_that(
- p.cargo("build")
- .arg("-p")
- .arg("d1")
- .arg("-p")
- .arg("d2")
- .arg("-p")
- .arg("foo"),
- execs().with_status(0),
- );
+ assert_that(p.cargo("build -p d1 -p d2 -p foo"), execs().with_status(0));
let d1_path = &p.build_dir()
.join("debug")
assert_that(d2_path, existing_file());
assert_that(
- p.cargo("clean")
- .arg("-p")
- .arg("d1")
- .arg("-p")
- .arg("d2")
- .cwd(&p.root().join("src")),
+ p.cargo("clean -p d1 -p d2").cwd(&p.root().join("src")),
execs().with_status(0).with_stdout(""),
);
assert_that(&p.bin("foo"), existing_file());
.build();
assert_that(
- p.cargo("run").arg("-q"),
+ p.cargo("run -q"),
execs().with_status(0).with_stdout("hello"),
);
assert_that(
- p.cargo("run").arg("--quiet"),
+ p.cargo("run --quiet"),
execs().with_status(0).with_stdout("hello"),
);
}
)
.build();
- assert_that(
- p.cargo("run")
- .arg("--bin")
- .arg("foo")
- .arg("hello")
- .arg("world"),
- execs().with_status(0),
- );
+ assert_that(p.cargo("run --bin foo hello world"), execs().with_status(0));
}
.build();
assert_that(
- p.cargo("rustc")
- .arg("-v")
- .arg("--bin")
- .arg("foo")
- .arg("--")
- .arg("-C")
- .arg("debug-assertions"),
+ p.cargo("rustc -v --bin foo -- -C debug-assertions"),
execs().with_status(0).with_stderr(&format!(
"\
[COMPILING] {name} v{version} ({url})
.build();
assert_that(
- p.cargo("rustc")
- .arg("-v")
- .arg("--bin")
- .arg("bar")
- .arg("--")
- .arg("-C")
- .arg("debug-assertions"),
+ p.cargo("rustc -v --bin bar -- -C debug-assertions"),
execs().with_status(0).with_stderr(format!(
"\
[COMPILING] foo v0.0.1 ({url})
.build();
assert_that(
- p.cargo("rustc")
- .arg("-v")
- .arg("--test")
- .arg("bar")
- .arg("--")
- .arg("-C")
- .arg("debug-assertions"),
+ p.cargo("rustc -v --test bar -- -C debug-assertions"),
execs().with_status(0).with_stderr(format!(
"\
[COMPILING] foo v0.0.1 ({url})
.build();
assert_that(
- foo.cargo("rustc")
- .arg("-v")
- .arg("-p")
- .arg("bar")
- .arg("--")
- .arg("-C")
- .arg("debug-assertions"),
+ foo.cargo("rustc -v -p bar -- -C debug-assertions"),
execs().with_status(0).with_stderr(
"\
[COMPILING] bar v0.1.0 ([..])
.build();
assert_that(
- foo.cargo("rustc")
- .arg("-v")
- .arg("-p")
- .arg("bar")
- .arg("-p")
- .arg("baz"),
+ foo.cargo("rustc -v -p bar -p baz"),
execs().with_status(1).with_stderr_contains(
"\
error: The argument '--package <SPEC>' was provided more than once, \
let p = p.build();
assert_that(
- p.cargo("test")
- .arg("-v")
- .arg("--no-run")
- .arg("--release")
- .arg("-p")
- .arg("foo")
- .arg("-p")
- .arg("a"),
+ p.cargo("test -v --no-run --release -p foo -p a"),
execs().with_status(0),
);
}
.file("a/src/lib.rs", "")
.build();
assert_that(
- p.cargo("test")
- .arg("--release")
- .arg("-v")
- .arg("-p")
- .arg("foo")
- .arg("-p")
- .arg("a"),
+ p.cargo("test --release -v -p foo -p a"),
execs().with_status(0),
);
}
.build();
assert_that(
- p.cargo("test")
- .arg("-v")
- .arg("-p")
- .arg("a")
- .arg("-p")
- .arg("foo")
- .arg("--features")
- .arg("foo"),
+ p.cargo("test -v -p a -p foo --features foo"),
execs().with_status(0),
);
}