Skip to content

Commit

Permalink
Add test for alias shadowing external subcommand
Browse files Browse the repository at this point in the history
This is currently still permitted, so we only test that the warning is properly issued
  • Loading branch information
basile-henry committed Nov 17, 2021
1 parent cba8503 commit 0b4e2ca
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/testsuite/cargo_alias_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 76,38 @@ fn dependent_alias() {
.run();
}

#[cargo_test]
fn alias_shadowing_external_subcommand() {
let echo = echo_subcommand();
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", "fn main() {}")
.file(
".cargo/config",
r#"
[alias]
echo = "build"
"#,
)
.build();

let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap_or_default()).collect();
paths.push(echo.target_debug_dir());
let path = env::join_paths(paths).unwrap();

p.cargo("echo")
.env("PATH", &path)
.with_stderr("\
[WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]`
This was previously accepted but is being phased out; it will become a hard error in a future release.
For more information, see issue #10049 <https://github.com/rust-lang/cargo/issues/10049>.
[COMPILING] foo v0.5.0 [..]
[FINISHED] dev [unoptimized debuginfo] target(s) in [..]
",
)
.run();
}

#[cargo_test]
fn default_args_alias() {
let echo = echo_subcommand();
Expand Down

0 comments on commit 0b4e2ca

Please sign in to comment.