From 0b4e2ca330b7dd536d57990ec3f5f090810b5bc9 Mon Sep 17 00:00:00 2001 From: Basile Henry Date: Wed, 17 Nov 2021 09:23:06 +0100 Subject: [PATCH] Add test for alias shadowing external subcommand This is currently still permitted, so we only test that the warning is properly issued --- tests/testsuite/cargo_alias_config.rs | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index 6d6a82b31..6777aeabf 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -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 . +[COMPILING] foo v0.5.0 [..] +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + #[cargo_test] fn default_args_alias() { let echo = echo_subcommand();