From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/cargo/tests/testsuite/build.rs | 137 ++++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-) (limited to 'src/tools/cargo/tests/testsuite/build.rs') diff --git a/src/tools/cargo/tests/testsuite/build.rs b/src/tools/cargo/tests/testsuite/build.rs index 1afa83918..23840ad9a 100644 --- a/src/tools/cargo/tests/testsuite/build.rs +++ b/src/tools/cargo/tests/testsuite/build.rs @@ -158,6 +158,29 @@ For more information, try '--help'. .run(); } +#[cargo_test] +fn cargo_compile_with_unsupported_short_config_flag() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .build(); + + p.cargo("build -c net.git-fetch-with-cli=true") + .with_stderr( + "\ +error: unexpected argument '-c' found + + tip: a similar argument exists: '--config' + +Usage: cargo[EXE] build [OPTIONS] + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} + #[cargo_test] fn cargo_compile_with_workspace_excluded() { let p = project().file("src/main.rs", "fn main() {}").build(); @@ -182,6 +205,30 @@ fn cargo_compile_manifest_path() { assert!(p.bin("foo").is_file()); } +#[cargo_test] +fn cargo_compile_with_wrong_manifest_path_flag() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .build(); + + p.cargo("build --path foo/Cargo.toml") + .cwd(p.root().parent().unwrap()) + .with_stderr( + "\ +error: unexpected argument '--path' found + + tip: a similar argument exists: '--manifest-path' + +Usage: cargo[EXE] build [OPTIONS] + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} + #[cargo_test] fn chdir_gated() { let p = project() @@ -221,6 +268,33 @@ fn cargo_compile_directory_not_cwd() { assert!(p.bin("foo").is_file()); } +#[cargo_test] +fn cargo_compile_with_unsupported_short_unstable_feature_flag() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .file(".cargo/config.toml", &"") + .build(); + + p.cargo("-zunstable-options -C foo build") + .masquerade_as_nightly_cargo(&["chdir"]) + .cwd(p.root().parent().unwrap()) + .with_stderr( + "\ +error: unexpected argument '-z' found + + tip: a similar argument exists: '-Z' + +Usage: cargo [..][OPTIONS] [COMMAND] + cargo [..][OPTIONS] -Zscript [ARGS]... + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} + #[cargo_test] fn cargo_compile_directory_not_cwd_with_invalid_config() { let p = project() @@ -465,7 +539,7 @@ fn cargo_compile_with_forbidden_bin_target_name() { [ERROR] failed to parse manifest at `[..]` Caused by: - the binary target name `build` is forbidden, it conflicts with with cargo's build directory names + the binary target name `build` is forbidden, it conflicts with cargo's build directory names ", ) .run(); @@ -4189,6 +4263,30 @@ fn cargo_build_empty_target() { .run(); } +#[cargo_test] +fn cargo_build_with_unsupported_short_target_flag() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("build -t") + .arg("") + .with_stderr( + "\ +error: unexpected argument '-t' found + + tip: a similar argument exists: '--target' + +Usage: cargo[EXE] build [OPTIONS] + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} + #[cargo_test] fn build_all_workspace() { let p = project() @@ -4254,6 +4352,43 @@ fn build_all_exclude() { .run(); } +#[cargo_test] +fn cargo_build_with_unsupported_short_exclude_flag() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [workspace] + members = ["bar", "baz"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("bar/src/lib.rs", "pub fn bar() {}") + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") + .build(); + + p.cargo("build --workspace -x baz") + .with_stderr( + "\ +error: unexpected argument '-x' found + + tip: a similar argument exists: '--exclude' + +Usage: cargo[EXE] build [OPTIONS] + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} + #[cargo_test] fn build_all_exclude_not_found() { let p = project() -- cgit v1.2.3