mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
test(cli): Verify precedence over external subcommands
This commit is contained in:
parent
21736eda0c
commit
b2b4d9771f
@ -110,7 +110,9 @@ impl FileBuilder {
|
|||||||
|
|
||||||
fn mk(&mut self) {
|
fn mk(&mut self) {
|
||||||
if self.executable {
|
if self.executable {
|
||||||
self.path.set_extension(env::consts::EXE_EXTENSION);
|
let mut path = self.path.clone().into_os_string();
|
||||||
|
write!(path, "{}", env::consts::EXE_SUFFIX).unwrap();
|
||||||
|
self.path = path.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dirname().mkdir_p();
|
self.dirname().mkdir_p();
|
||||||
|
@ -9,6 +9,10 @@ fn main() {
|
|||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
|
fn path() -> Vec<std::path::PathBuf> {
|
||||||
|
std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()).collect()
|
||||||
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn basic_rs() {
|
fn basic_rs() {
|
||||||
let p = cargo_test_support::project()
|
let p = cargo_test_support::project()
|
||||||
@ -68,6 +72,57 @@ error: no such command: `echo`
|
|||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn manifest_precedence_over_plugins() {
|
||||||
|
let p = cargo_test_support::project()
|
||||||
|
.file("echo.rs", ECHO_SCRIPT)
|
||||||
|
.executable(std::path::Path::new("path-test").join("cargo-echo.rs"), "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// With path - fmt is there with known description
|
||||||
|
let mut path = path();
|
||||||
|
path.push(p.root().join("path-test"));
|
||||||
|
let path = std::env::join_paths(path.iter()).unwrap();
|
||||||
|
|
||||||
|
p.cargo("-Zscript echo.rs")
|
||||||
|
.arg("--help") // An arg that, if processed by cargo, will cause problems
|
||||||
|
.env("PATH", &path)
|
||||||
|
.masquerade_as_nightly_cargo(&["script"])
|
||||||
|
.with_status(101)
|
||||||
|
.with_stdout("")
|
||||||
|
.with_stderr("\
|
||||||
|
thread 'main' panicked at 'not yet implemented: support for running manifest-commands is not yet implemented', [..]
|
||||||
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||||
|
")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn manifest_precedence_over_plugins_stable() {
|
||||||
|
let p = cargo_test_support::project()
|
||||||
|
.file("echo.rs", ECHO_SCRIPT)
|
||||||
|
.executable(std::path::Path::new("path-test").join("cargo-echo.rs"), "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let mut path = path();
|
||||||
|
path.push(p.root().join("path-test"));
|
||||||
|
let path = std::env::join_paths(path.iter()).unwrap();
|
||||||
|
|
||||||
|
p.cargo("echo.rs")
|
||||||
|
.arg("--help") // An arg that, if processed by cargo, will cause problems
|
||||||
|
.env("PATH", &path)
|
||||||
|
.with_status(101)
|
||||||
|
.with_stdout("")
|
||||||
|
.with_stderr(
|
||||||
|
"\
|
||||||
|
error: running `echo.rs` requires `-Zscript`
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn requires_nightly() {
|
fn requires_nightly() {
|
||||||
let p = cargo_test_support::project()
|
let p = cargo_test_support::project()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user