From c23a457e72abe608715ac76f076f47dc42af07a5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:44 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/cargo/tests/testsuite/alt_registry.rs | 7 +- src/tools/cargo/tests/testsuite/artifact_dep.rs | 140 ++++++++++- src/tools/cargo/tests/testsuite/bad_config.rs | 152 ++++++++++-- src/tools/cargo/tests/testsuite/bench.rs | 18 -- src/tools/cargo/tests/testsuite/build.rs | 37 ++- src/tools/cargo/tests/testsuite/build_script.rs | 37 +++ .../cargo/tests/testsuite/cargo/help/stdout.log | 5 +- .../features_activated_over_limit/in/Cargo.toml | 5 + .../features_activated_over_limit/in/src/lib.rs | 0 .../cargo_add/features_activated_over_limit/mod.rs | 38 +++ .../features_activated_over_limit/out/Cargo.toml | 8 + .../features_activated_over_limit/stderr.log | 5 + .../features_activated_over_limit/stdout.log | 0 .../features_deactivated_over_limit/in/Cargo.toml | 5 + .../features_deactivated_over_limit/in/src/lib.rs | 0 .../features_deactivated_over_limit/mod.rs | 38 +++ .../features_deactivated_over_limit/out/Cargo.toml | 8 + .../features_deactivated_over_limit/stderr.log | 34 +++ .../features_deactivated_over_limit/stdout.log | 0 .../tests/testsuite/cargo_add/help/stdout.log | 2 +- .../cargo_add/invalid_manifest/stderr.log | 3 - src/tools/cargo/tests/testsuite/cargo_add/mod.rs | 2 + .../testsuite/cargo_add/rust_version_ignore/mod.rs | 2 +- .../cargo_add/rust_version_ignore/stderr.log | 5 + .../cargo/tests/testsuite/cargo_alias_config.rs | 3 - .../tests/testsuite/cargo_bench/help/stdout.log | 2 +- src/tools/cargo/tests/testsuite/cargo_bench/mod.rs | 1 + .../cargo_bench/no_keep_going/in/Cargo.toml | 3 + .../cargo_bench/no_keep_going/in/src/lib.rs | 0 .../testsuite/cargo_bench/no_keep_going/mod.rs | 19 ++ .../testsuite/cargo_bench/no_keep_going/stderr.log | 7 + .../testsuite/cargo_bench/no_keep_going/stdout.log | 0 .../tests/testsuite/cargo_build/help/stdout.log | 4 +- .../tests/testsuite/cargo_check/help/stdout.log | 4 +- .../tests/testsuite/cargo_clean/help/stdout.log | 3 +- .../cargo/tests/testsuite/cargo_config/mod.rs | 22 +- .../tests/testsuite/cargo_doc/help/stdout.log | 4 +- src/tools/cargo/tests/testsuite/cargo_features.rs | 7 +- .../tests/testsuite/cargo_fetch/help/stdout.log | 2 +- .../tests/testsuite/cargo_fix/help/stdout.log | 4 +- .../out/.fossil-settings/clean-glob | 1 - .../out/.fossil-settings/ignore-glob | 1 - .../tests/testsuite/cargo_init/help/stdout.log | 7 +- .../cargo_init/pijul_autodetect/out/.ignore | 1 - .../tests/testsuite/cargo_install/help/stdout.log | 4 +- .../tests/testsuite/cargo_login/help/stdout.log | 2 +- .../tests/testsuite/cargo_new/help/stdout.log | 7 +- .../cargo_new/inherit_workspace_lints/mod.rs | 4 +- src/tools/cargo/tests/testsuite/cargo_new/mod.rs | 2 +- .../in/Cargo.toml | 15 ++ .../in/README.md | 0 .../in/src/lib.rs | 14 ++ .../mod.rs | 22 ++ .../out/Cargo.toml | 15 ++ .../out/foo/Cargo.toml | 21 ++ .../out/foo/src/main.rs | 3 + .../out/src/lib.rs | 14 ++ .../stderr.log | 9 + .../stdout.log | 0 .../in/Cargo.toml | 15 -- .../in/README.md | 0 .../in/src/lib.rs | 14 -- .../mod.rs | 22 -- .../out/Cargo.toml | 15 -- .../out/foo/Cargo.toml | 21 -- .../out/foo/src/main.rs | 3 - .../out/src/lib.rs | 14 -- .../stderr.log | 9 - .../stdout.log | 0 .../tests/testsuite/cargo_owner/help/stdout.log | 4 +- .../tests/testsuite/cargo_package/help/stdout.log | 4 +- .../tests/testsuite/cargo_publish/help/stdout.log | 8 +- .../tests/testsuite/cargo_remove/help/stdout.log | 4 +- .../cargo/tests/testsuite/cargo_remove/mod.rs | 1 + .../skip_gc_glob_profile/in/Cargo.toml | 13 + .../skip_gc_glob_profile/in/src/lib.rs | 1 + .../cargo_remove/skip_gc_glob_profile/mod.rs | 25 ++ .../skip_gc_glob_profile/out/Cargo.toml | 10 + .../cargo_remove/skip_gc_glob_profile/stderr.log | 1 + .../cargo_remove/skip_gc_glob_profile/stdout.log | 0 .../tests/testsuite/cargo_run/help/stdout.log | 4 +- .../tests/testsuite/cargo_rustc/help/stdout.log | 4 +- .../tests/testsuite/cargo_rustdoc/help/stdout.log | 4 +- .../tests/testsuite/cargo_search/help/stdout.log | 4 +- .../tests/testsuite/cargo_test/help/stdout.log | 2 +- src/tools/cargo/tests/testsuite/cargo_test/mod.rs | 1 + .../cargo_test/no_keep_going/in/Cargo.toml | 3 + .../cargo_test/no_keep_going/in/src/lib.rs | 0 .../testsuite/cargo_test/no_keep_going/mod.rs | 19 ++ .../testsuite/cargo_test/no_keep_going/stderr.log | 7 + .../testsuite/cargo_test/no_keep_going/stdout.log | 0 .../tests/testsuite/cargo_tree/help/stdout.log | 4 +- .../tests/testsuite/cargo_update/help/stdout.log | 12 +- .../cargo/tests/testsuite/cargo_update/mod.rs | 1 + .../cargo_update/toolchain_pkgname/in/Cargo.toml | 5 + .../cargo_update/toolchain_pkgname/in/src/main.rs | 3 + .../cargo_update/toolchain_pkgname/mod.rs | 19 ++ .../cargo_update/toolchain_pkgname/stderr.log | 2 + .../cargo_update/toolchain_pkgname/stdout.log | 0 .../tests/testsuite/cargo_yank/help/stdout.log | 4 +- src/tools/cargo/tests/testsuite/check.rs | 3 +- src/tools/cargo/tests/testsuite/clean.rs | 201 +++++++++++++++- src/tools/cargo/tests/testsuite/config.rs | 24 +- src/tools/cargo/tests/testsuite/config_cli.rs | 10 +- .../cargo/tests/testsuite/credential_process.rs | 262 ++++++++++++--------- src/tools/cargo/tests/testsuite/doc.rs | 4 +- src/tools/cargo/tests/testsuite/features2.rs | 3 +- src/tools/cargo/tests/testsuite/freshness.rs | 4 +- .../tests/testsuite/future_incompat_report.rs | 2 +- src/tools/cargo/tests/testsuite/git.rs | 29 +-- .../testsuite/inheritable_workspace_fields.rs | 8 +- src/tools/cargo/tests/testsuite/install.rs | 51 +++- src/tools/cargo/tests/testsuite/install_upgrade.rs | 8 +- src/tools/cargo/tests/testsuite/lints.rs | 197 +++++++--------- src/tools/cargo/tests/testsuite/list_availables.rs | 39 ++- src/tools/cargo/tests/testsuite/login.rs | 16 +- src/tools/cargo/tests/testsuite/logout.rs | 23 +- src/tools/cargo/tests/testsuite/lto.rs | 6 +- src/tools/cargo/tests/testsuite/metadata.rs | 21 +- src/tools/cargo/tests/testsuite/new.rs | 4 +- src/tools/cargo/tests/testsuite/offline.rs | 4 +- src/tools/cargo/tests/testsuite/owner.rs | 8 +- src/tools/cargo/tests/testsuite/patch.rs | 48 +++- src/tools/cargo/tests/testsuite/pkgid.rs | 131 ++++++++--- src/tools/cargo/tests/testsuite/profile_config.rs | 4 +- src/tools/cargo/tests/testsuite/profile_custom.rs | 4 +- .../cargo/tests/testsuite/profile_overrides.rs | 54 +++++ src/tools/cargo/tests/testsuite/profiles.rs | 2 +- src/tools/cargo/tests/testsuite/publish.rs | 47 +++- src/tools/cargo/tests/testsuite/registry.rs | 67 ++++-- src/tools/cargo/tests/testsuite/registry_auth.rs | 23 +- src/tools/cargo/tests/testsuite/replace.rs | 158 ++++++++++++- src/tools/cargo/tests/testsuite/run.rs | 37 +++ src/tools/cargo/tests/testsuite/rust_version.rs | 253 +++++++++++++++++++- src/tools/cargo/tests/testsuite/rustdocflags.rs | 8 +- src/tools/cargo/tests/testsuite/script.rs | 37 ++- src/tools/cargo/tests/testsuite/search.rs | 9 +- .../cargo/tests/testsuite/source_replacement.rs | 47 +++- src/tools/cargo/tests/testsuite/ssh.rs | 3 +- src/tools/cargo/tests/testsuite/test.rs | 18 -- src/tools/cargo/tests/testsuite/tool_paths.rs | 88 ++++++- src/tools/cargo/tests/testsuite/tree.rs | 2 +- src/tools/cargo/tests/testsuite/update.rs | 257 ++++++++++++++++++-- src/tools/cargo/tests/testsuite/workspaces.rs | 3 - src/tools/cargo/tests/testsuite/yank.rs | 8 +- 145 files changed, 2559 insertions(+), 736 deletions(-) create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/out/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stdout.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/out/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stdout.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stdout.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/README.md create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/src/main.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stdout.log delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/README.md delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log delete mode 100644 src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stdout.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/out/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stdout.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/src/lib.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stdout.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/Cargo.toml create mode 100644 src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/src/main.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/mod.rs create mode 100644 src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stderr.log create mode 100644 src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stdout.log (limited to 'src/tools/cargo/tests') diff --git a/src/tools/cargo/tests/testsuite/alt_registry.rs b/src/tools/cargo/tests/testsuite/alt_registry.rs index 91157cd53..d6d7dd531 100644 --- a/src/tools/cargo/tests/testsuite/alt_registry.rs +++ b/src/tools/cargo/tests/testsuite/alt_registry.rs @@ -1389,10 +1389,9 @@ fn both_index_and_registry() { p.cargo(cmd) .arg("--registry=foo") .arg("--index=foo") - .with_status(101) - .with_stderr( - "[ERROR] both `--index` and `--registry` \ - should not be set at the same time", + .with_status(1) + .with_stderr_contains( + "error: the argument '--registry ' cannot be used with '--index '", ) .run(); } diff --git a/src/tools/cargo/tests/testsuite/artifact_dep.rs b/src/tools/cargo/tests/testsuite/artifact_dep.rs index 08e413bf5..64aa9d8af 100644 --- a/src/tools/cargo/tests/testsuite/artifact_dep.rs +++ b/src/tools/cargo/tests/testsuite/artifact_dep.rs @@ -1445,13 +1445,7 @@ foo v0.0.0 ([CWD]) ) .run(); } - -// TODO: Fix this potentially by reverting 887562bfeb8c540594d7d08e6e9a4ab7eb255865 which adds artifact information to the registry -// followed by 0ff93733626f7cbecaf9dce9ab62b4ced0be088e which picks it up. -// For reference, see comments by ehuss https://github.com/rust-lang/cargo/pull/9992#discussion_r801086315 and -// joshtriplett https://github.com/rust-lang/cargo/pull/9992#issuecomment-1033394197 . #[cargo_test] -#[ignore = "broken, need artifact info in index"] fn targets_are_picked_up_from_non_workspace_artifact_deps() { if cross_compile::disabled() { return; @@ -1464,6 +1458,7 @@ fn targets_are_picked_up_from_non_workspace_artifact_deps() { let mut dep = registry::Dependency::new("artifact", "1.0.0"); Package::new("uses-artifact", "1.0.0") + .schema_version(3) .file( "src/lib.rs", r#"pub fn uses_artifact() { let _b = include_bytes!(env!("CARGO_BIN_FILE_ARTIFACT")); }"#, @@ -1495,6 +1490,127 @@ fn targets_are_picked_up_from_non_workspace_artifact_deps() { .run(); } +#[cargo_test] +fn index_version_filtering() { + if cross_compile::disabled() { + return; + } + let target = cross_compile::alternate(); + + Package::new("artifact", "1.0.0") + .file("src/main.rs", r#"fn main() {}"#) + .file("src/lib.rs", r#"pub fn lib() {}"#) + .publish(); + + let mut dep = registry::Dependency::new("artifact", "1.0.0"); + + Package::new("bar", "1.0.0").publish(); + Package::new("bar", "1.0.1") + .schema_version(3) + .add_dep(dep.artifact("bin", Some(target.to_string()))) + .publish(); + + // Verify that without `-Zbindeps` that it does not use 1.0.1. + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = "1.0" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("tree") + .with_stdout("foo v0.1.0 [..]\n└── bar v1.0.0") + .run(); + + // And with -Zbindeps it can use 1.0.1. + p.cargo("update -Zbindeps") + .masquerade_as_nightly_cargo(&["bindeps"]) + .with_stderr( + "\ +[UPDATING] [..] +[ADDING] artifact v1.0.0 +[UPDATING] bar v1.0.0 -> v1.0.1", + ) + .run(); + + // And without -Zbindeps, now that 1.0.1 is in Cargo.lock, it should fail. + p.cargo("check") + .with_status(101) + .with_stderr( + "\ +[UPDATING] [..] +error: failed to select a version for the requirement `bar = \"^1.0\"` (locked to 1.0.1) +candidate versions found which didn't match: 1.0.0 +location searched: [..] +required by package `foo v0.1.0 [..]` +perhaps a crate was updated and forgotten to be re-vendored?", + ) + .run(); +} + +// FIXME: `download_accessible` should work properly for artifact dependencies +#[cargo_test] +#[ignore = "broken, needs download_accessible fix"] +fn proc_macro_in_artifact_dep() { + // Forcing FeatureResolver to check a proc-macro for a dependency behind a + // target dependency. + if cross_compile::disabled() { + return; + } + Package::new("pm", "1.0.0") + .file("src/lib.rs", "") + .file( + "Cargo.toml", + r#" + [package] + name = "pm" + version = "1.0.0" + + [lib] + proc-macro = true + + "#, + ) + .publish(); + let alternate = cross_compile::alternate(); + Package::new("bin-uses-pm", "1.0.0") + .target_dep("pm", "1.0", alternate) + .file("src/main.rs", "fn main() {}") + .publish(); + // Simulate a network error downloading the proc-macro. + std::fs::remove_file(cargo_test_support::paths::root().join("dl/pm/1.0.0/download")).unwrap(); + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2021" + + [dependencies] + bin-uses-pm = {{ version = "1.0", artifact = "bin", target = "{alternate}"}} + "# + ), + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check -Z bindeps") + .masquerade_as_nightly_cargo(&["bindeps"]) + .with_stderr("") + .run(); +} + #[cargo_test] fn allow_dep_renames_with_multiple_versions() { Package::new("bar", "1.0.0") @@ -1926,15 +2042,23 @@ You may press ctrl-c [..] "badges": {}, "categories": [], "deps": [{ + "artifact": ["bin"], "default_features": true, "features": [], "kind": "normal", + "lib": true, "name": "bar", "optional": false, "target": null, "version_req": "^1.0" }, { + "artifact": [ + "bin:a", + "cdylib", + "staticlib" + ], + "bindep_target": "target", "default_features": true, "features": [], "kind": "build", @@ -2894,8 +3018,8 @@ fn check_transitive_artifact_dependency_with_different_target() { p.cargo("check -Z bindeps") .masquerade_as_nightly_cargo(&["bindeps"]) .with_stderr_contains( - "error: could not find specification for target `custom-target`.\n \ - Dependency `baz v0.0.0 [..]` requires to build for target `custom-target`.", + "error: failed to determine target information for target `custom-target`.\n \ + Artifact dependency `baz` in package `bar v0.0.0 [..]` requires building for `custom-target`", ) .with_status(101) .run(); diff --git a/src/tools/cargo/tests/testsuite/bad_config.rs b/src/tools/cargo/tests/testsuite/bad_config.rs index 4434ea90d..82da880ea 100644 --- a/src/tools/cargo/tests/testsuite/bad_config.rs +++ b/src/tools/cargo/tests/testsuite/bad_config.rs @@ -171,9 +171,6 @@ fn invalid_global_config() { Caused by: could not parse TOML configuration in `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 1, column 2 | @@ -199,8 +196,11 @@ fn bad_cargo_lock() { [ERROR] failed to parse lock file at: [..]Cargo.lock Caused by: + TOML parse error at line 1, column 1 + | + 1 | [[package]] + | ^^^^^^^^^^^ missing field `name` - in `package` ", ) .run(); @@ -303,8 +303,11 @@ fn bad_source_in_cargo_lock() { [ERROR] failed to parse lock file at: [..] Caused by: + TOML parse error at line 12, column 26 + | + 12 | source = \"You shall not parse\" + | ^^^^^^^^^^^^^^^^^^^^^ invalid source `You shall not parse` - in `package.source` ", ) .run(); @@ -448,9 +451,6 @@ fn malformed_override() { "\ [ERROR] failed to parse manifest at `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 8, column 27 | @@ -803,9 +803,6 @@ error: could not load Cargo configuration Caused by: could not parse TOML configuration in `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 1, column 7 | @@ -1288,8 +1285,11 @@ fn bad_dependency() { error: failed to parse manifest at `[..]` Caused by: + TOML parse error at line 8, column 23 + | + 8 | bar = 3 + | ^ invalid type: integer `3`, expected a version string like [..] - in `dependencies.bar` ", ) .run(); @@ -1320,8 +1320,11 @@ fn bad_debuginfo() { error: failed to parse manifest [..] Caused by: + TOML parse error at line 8, column 25 + | + 8 | debug = 'a' + | ^^^ invalid value: string \"a\", expected a boolean, 0, 1, 2, \"line-tables-only\", or \"line-directives-only\" - in `profile.dev.debug` ", ) .run(); @@ -1352,8 +1355,11 @@ fn bad_debuginfo2() { error: failed to parse manifest at `[..]` Caused by: + TOML parse error at line 8, column 25 + | + 8 | debug = 3.6 + | ^^^ invalid type: floating point `3.6`, expected a boolean, 0, 1, 2, \"line-tables-only\", or \"line-directives-only\" - in `profile.dev.debug` ", ) .run(); @@ -1382,8 +1388,11 @@ fn bad_opt_level() { error: failed to parse manifest at `[..]` Caused by: - expected a boolean or a string - in `package.build` + TOML parse error at line 6, column 25 + | + 6 | build = 3 + | ^ + invalid type: integer `3`, expected a boolean or string ", ) .run(); @@ -1411,6 +1420,117 @@ fn warn_semver_metadata() { .run(); } +#[cargo_test] +fn bad_http_ssl_version() { + // Invalid type in SslVersionConfig. + let p = project() + .file( + ".cargo/config.toml", + r#" + [http] + ssl-version = ["tlsv1.2", "tlsv1.3"] + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] error in [..]/config.toml: could not load config key `http.ssl-version` + +Caused by: + invalid type: sequence, expected a string or map +", + ) + .run(); +} + +#[cargo_test] +fn bad_http_ssl_version_range() { + // Invalid type in SslVersionConfigRange. + let p = project() + .file( + ".cargo/config.toml", + r#" + [http] + ssl-version.min = false + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] error in [..]/config.toml: could not load config key `http.ssl-version` + +Caused by: + error in [..]/config.toml: `http.ssl-version.min` expected a string, but found a boolean +", + ) + .run(); +} + +#[cargo_test] +fn bad_build_jobs() { + // Invalid type in JobsConfig. + let p = project() + .file( + ".cargo/config.toml", + r#" + [build] + jobs = { default = true } + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] error in [..]/config.toml: could not load config key `build.jobs` + +Caused by: + invalid type: map, expected an integer or string +", + ) + .run(); +} + +#[cargo_test] +fn bad_build_target() { + // Invalid type in BuildTargetConfig. + let p = project() + .file( + ".cargo/config.toml", + r#" + [build] + target.'cfg(unix)' = "x86_64" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] error in [..]/config.toml: could not load config key `build.target` + +Caused by: + error in [..]/config.toml: could not load config key `build.target` + +Caused by: + invalid type: map, expected a string or array +", + ) + .run(); +} + #[cargo_test] fn bad_target_cfg() { // Invalid type in a StringList. diff --git a/src/tools/cargo/tests/testsuite/bench.rs b/src/tools/cargo/tests/testsuite/bench.rs index d773308c6..01017e857 100644 --- a/src/tools/cargo/tests/testsuite/bench.rs +++ b/src/tools/cargo/tests/testsuite/bench.rs @@ -1671,24 +1671,6 @@ fn json_artifact_includes_executable_for_benchmark() { .run(); } -#[cargo_test] -fn cargo_bench_no_keep_going() { - let p = project() - .file("Cargo.toml", &basic_bin_manifest("foo")) - .file("src/main.rs", "") - .build(); - - p.cargo("bench --keep-going") - .with_stderr( - "\ -error: unexpected argument `--keep-going` found - - tip: to run as many benchmarks as possible without failing fast, use `--no-fail-fast`", - ) - .with_status(101) - .run(); -} - #[cargo_test(nightly, reason = "bench")] fn cargo_bench_print_env_verbose() { let p = project() diff --git a/src/tools/cargo/tests/testsuite/build.rs b/src/tools/cargo/tests/testsuite/build.rs index 8cb064a6f..1afa83918 100644 --- a/src/tools/cargo/tests/testsuite/build.rs +++ b/src/tools/cargo/tests/testsuite/build.rs @@ -135,6 +135,29 @@ fn incremental_config() { .run(); } +#[cargo_test] +fn cargo_compile_with_redundant_default_mode() { + let p = project() + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .build(); + + p.cargo("build --debug") + .with_stderr( + "\ +error: unexpected argument '--debug' found + + tip: `--debug` is the default for `cargo build`; instead `--release` is supported + +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(); @@ -258,9 +281,6 @@ fn cargo_compile_with_invalid_manifest2() { "\ [ERROR] failed to parse manifest at `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 3, column 23 | @@ -283,9 +303,6 @@ fn cargo_compile_with_invalid_manifest3() { "\ [ERROR] failed to parse manifest at `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 1, column 5 | @@ -346,8 +363,11 @@ fn cargo_compile_with_invalid_version() { [ERROR] failed to parse manifest at `[..]` Caused by: + TOML parse error at line 4, column 19 + | + 4 | version = \"1.0\" + | ^^^^^ unexpected end of input while parsing minor version number - in `package.version` ", ) .run(); @@ -3035,9 +3055,6 @@ fn bad_cargo_config() { Caused by: could not parse TOML configuration in `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 1, column 6 | diff --git a/src/tools/cargo/tests/testsuite/build_script.rs b/src/tools/cargo/tests/testsuite/build_script.rs index 400d10547..0ccbb4e27 100644 --- a/src/tools/cargo/tests/testsuite/build_script.rs +++ b/src/tools/cargo/tests/testsuite/build_script.rs @@ -453,6 +453,43 @@ fn custom_build_env_var_rustc_linker() { p.cargo("build --target").arg(&target).run(); } +// Only run this test on linux, since it's difficult to construct +// a case suitable for all platforms. +// See:https://github.com/rust-lang/cargo/pull/12535#discussion_r1306618264 +#[cargo_test] +#[cfg(target_os = "linux")] +fn custom_build_env_var_rustc_linker_with_target_cfg() { + if cross_compile::disabled() { + return; + } + + let target = cross_compile::alternate(); + let p = project() + .file( + ".cargo/config", + r#" + [target.'cfg(target_pointer_width = "32")'] + linker = "/path/to/linker" + "#, + ) + .file( + "build.rs", + r#" + use std::env; + + fn main() { + assert!(env::var("RUSTC_LINKER").unwrap().ends_with("/path/to/linker")); + } + "#, + ) + .file("src/lib.rs", "") + .build(); + + // no crate type set => linker never called => build succeeds if and + // only if build.rs succeeds, despite linker binary not existing. + p.cargo("build --target").arg(&target).run(); +} + #[cargo_test] fn custom_build_env_var_rustc_linker_bad_host_target() { let target = rustc_host(); diff --git a/src/tools/cargo/tests/testsuite/cargo/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo/help/stdout.log index 26bcd745b..e15848ab7 100644 --- a/src/tools/cargo/tests/testsuite/cargo/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo/help/stdout.log @@ -6,7 +6,7 @@ Usage: cargo [..][OPTIONS] [COMMAND] Options: -V, --version Print version info and exit --list List installed commands - --explain Run `rustc --explain CODE` + --explain Provide a detailed explanation of a rustc error message -v, --verbose... Use verbose output (-vv very verbose/build.rs output) -q, --quiet Do not print cargo log messages --color Coloring: auto, always, never @@ -18,7 +18,7 @@ Options: -Z Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details -h, --help Print help -Some common cargo commands are (see all commands with --list): +Commands: build, b Compile the current package check, c Analyze the current package and report errors, but don't build object files clean Remove the target directory @@ -35,5 +35,6 @@ Some common cargo commands are (see all commands with --list): publish Package and upload this package to the registry install Install a Rust binary. Default location is $HOME/.cargo/bin uninstall Uninstall a Rust binary + ... See all commands with --list See 'cargo help ' for more information on a specific command. diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/Cargo.toml new file mode 100644 index 000000000..3ecdb6681 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/in/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/mod.rs new file mode 100644 index 000000000..467e9a681 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/mod.rs @@ -0,0 +1,38 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; +use itertools::Itertools; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + const MANY_FEATURES_COUNT: usize = 200; + const ACTIVATED_FEATURES_COUNT: usize = 100; + + cargo_test_support::registry::init(); + let mut test_package = + cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package"); + for i in 0..MANY_FEATURES_COUNT { + test_package.feature(format!("eyes{i:03}").as_str(), &[]); + } + test_package.publish(); + + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + let features = (0..ACTIVATED_FEATURES_COUNT) + .map(|i| format!("eyes{i:03}")) + .join(","); + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line(format!("your-face --features {features}").as_str()) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/out/Cargo.toml new file mode 100644 index 000000000..6c8c7e5a3 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/out/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" + +[dependencies] +your-face = { version = "99999.0.0", features = ["eyes000", "eyes001", "eyes002", "eyes003", "eyes004", "eyes005", "eyes006", "eyes007", "eyes008", "eyes009", "eyes010", "eyes011", "eyes012", "eyes013", "eyes014", "eyes015", "eyes016", "eyes017", "eyes018", "eyes019", "eyes020", "eyes021", "eyes022", "eyes023", "eyes024", "eyes025", "eyes026", "eyes027", "eyes028", "eyes029", "eyes030", "eyes031", "eyes032", "eyes033", "eyes034", "eyes035", "eyes036", "eyes037", "eyes038", "eyes039", "eyes040", "eyes041", "eyes042", "eyes043", "eyes044", "eyes045", "eyes046", "eyes047", "eyes048", "eyes049", "eyes050", "eyes051", "eyes052", "eyes053", "eyes054", "eyes055", "eyes056", "eyes057", "eyes058", "eyes059", "eyes060", "eyes061", "eyes062", "eyes063", "eyes064", "eyes065", "eyes066", "eyes067", "eyes068", "eyes069", "eyes070", "eyes071", "eyes072", "eyes073", "eyes074", "eyes075", "eyes076", "eyes077", "eyes078", "eyes079", "eyes080", "eyes081", "eyes082", "eyes083", "eyes084", "eyes085", "eyes086", "eyes087", "eyes088", "eyes089", "eyes090", "eyes091", "eyes092", "eyes093", "eyes094", "eyes095", "eyes096", "eyes097", "eyes098", "eyes099"] } diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stderr.log new file mode 100644 index 000000000..9288319aa --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stderr.log @@ -0,0 +1,5 @@ + Updating `dummy-registry` index + Adding your-face v99999.0.0 to dependencies. + Features: + 100 activated features + 100 deactivated features diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stdout.log b/src/tools/cargo/tests/testsuite/cargo_add/features_activated_over_limit/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/Cargo.toml new file mode 100644 index 000000000..3ecdb6681 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/in/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/mod.rs new file mode 100644 index 000000000..b2ed6f87d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/mod.rs @@ -0,0 +1,38 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; +use itertools::Itertools; + +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + const MANY_FEATURES_COUNT: usize = 200; + const ACTIVATED_FEATURES_COUNT: usize = 30; + + cargo_test_support::registry::init(); + let mut test_package = + cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package"); + for i in 0..MANY_FEATURES_COUNT { + test_package.feature(format!("eyes{i:03}").as_str(), &[]); + } + test_package.publish(); + + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + let features = (0..ACTIVATED_FEATURES_COUNT) + .map(|i| format!("eyes{i:03}")) + .join(","); + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line(format!("your-face --features {features}").as_str()) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/out/Cargo.toml new file mode 100644 index 000000000..b94cde668 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/out/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" + +[dependencies] +your-face = { version = "99999.0.0", features = ["eyes000", "eyes001", "eyes002", "eyes003", "eyes004", "eyes005", "eyes006", "eyes007", "eyes008", "eyes009", "eyes010", "eyes011", "eyes012", "eyes013", "eyes014", "eyes015", "eyes016", "eyes017", "eyes018", "eyes019", "eyes020", "eyes021", "eyes022", "eyes023", "eyes024", "eyes025", "eyes026", "eyes027", "eyes028", "eyes029"] } diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stderr.log new file mode 100644 index 000000000..7f74e6bf0 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stderr.log @@ -0,0 +1,34 @@ + Updating `dummy-registry` index + Adding your-face v99999.0.0 to dependencies. + Features: + + eyes000 + + eyes001 + + eyes002 + + eyes003 + + eyes004 + + eyes005 + + eyes006 + + eyes007 + + eyes008 + + eyes009 + + eyes010 + + eyes011 + + eyes012 + + eyes013 + + eyes014 + + eyes015 + + eyes016 + + eyes017 + + eyes018 + + eyes019 + + eyes020 + + eyes021 + + eyes022 + + eyes023 + + eyes024 + + eyes025 + + eyes026 + + eyes027 + + eyes028 + + eyes029 + 170 deactivated features diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stdout.log b/src/tools/cargo/tests/testsuite/cargo_add/features_deactivated_over_limit/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_add/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_add/help/stdout.log index 0daba1a94..cf2a91313 100644 --- a/src/tools/cargo/tests/testsuite/cargo_add/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_add/help/stdout.log @@ -42,7 +42,7 @@ Options: --ignore-rust-version Ignore `rust-version` specification in packages (unstable) - --dry-run + -n, --dry-run Don't actually write the manifest -q, --quiet diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/stderr.log index 3dabde349..9a8a93b5e 100644 --- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/stderr.log +++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/stderr.log @@ -1,8 +1,5 @@ error: failed to parse manifest at `[ROOT]/case/Cargo.toml` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 8, column 7 | diff --git a/src/tools/cargo/tests/testsuite/cargo_add/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/mod.rs index de93afbc1..8c03b30dc 100644 --- a/src/tools/cargo/tests/testsuite/cargo_add/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_add/mod.rs @@ -18,6 +18,8 @@ mod dev_prefer_existing_version; mod dry_run; mod empty_dep_table; mod features; +mod features_activated_over_limit; +mod features_deactivated_over_limit; mod features_empty; mod features_multiple_occurrences; mod features_preserve; diff --git a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/mod.rs index a382d95f1..f8aac0ad8 100644 --- a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/mod.rs @@ -26,7 +26,7 @@ fn case() { .current_dir(cwd) .masquerade_as_nightly_cargo(&["msrv-policy"]) .assert() - .success() + .code(101) .stdout_matches_path(curr_dir!().join("stdout.log")) .stderr_matches_path(curr_dir!().join("stderr.log")); diff --git a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/stderr.log index 430abe31b..96bcbddc2 100644 --- a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/stderr.log +++ b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/stderr.log @@ -1,2 +1,7 @@ Updating `dummy-registry` index Adding rust-version-user v0.2.1 to dependencies. +error: failed to select a version for the requirement `rust-version-user = "^0.2.1"` +candidate versions found which didn't match: 0.2.1, 0.1.0 +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `cargo-list-test-fixture v0.0.0 ([ROOT]/case)` +perhaps a crate was updated and forgotten to be re-vendored? diff --git a/src/tools/cargo/tests/testsuite/cargo_alias_config.rs b/src/tools/cargo/tests/testsuite/cargo_alias_config.rs index fd4aec917..679ca3d5f 100644 --- a/src/tools/cargo/tests/testsuite/cargo_alias_config.rs +++ b/src/tools/cargo/tests/testsuite/cargo_alias_config.rs @@ -52,9 +52,6 @@ fn alias_malformed_config_string() { Caused by: could not parse TOML configuration in `[..]/config` -Caused by: - [..] - Caused by: TOML parse error at line [..] | diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_bench/help/stdout.log index 5d9484df9..430d8be42 100644 --- a/src/tools/cargo/tests/testsuite/cargo_bench/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_bench/help/stdout.log @@ -45,7 +45,7 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. --profile Build artifacts with the specified profile - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/mod.rs b/src/tools/cargo/tests/testsuite/cargo_bench/mod.rs index c0ce11180..28be9d1a7 100644 --- a/src/tools/cargo/tests/testsuite/cargo_bench/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_bench/mod.rs @@ -1 +1,2 @@ mod help; +mod no_keep_going; diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/Cargo.toml new file mode 100644 index 000000000..c35d63273 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/Cargo.toml @@ -0,0 +1,3 @@ +[package] +name = "foo" +version = "0.1.0" diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/in/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/mod.rs b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/mod.rs new file mode 100644 index 000000000..6ed5f81f9 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/mod.rs @@ -0,0 +1,19 @@ +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("bench") + .arg("--keep-going") + .current_dir(cwd) + .assert() + .code(1) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stderr.log b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stderr.log new file mode 100644 index 000000000..7b94abbc4 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stderr.log @@ -0,0 +1,7 @@ +error: unexpected argument '--keep-going' found + + tip: use `--no-fail-fast` to run as many tests as possible regardless of failure + +Usage: cargo[EXE] bench [OPTIONS] [BENCHNAME] [-- [args]...] + +For more information, try '--help'. diff --git a/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stdout.log b/src/tools/cargo/tests/testsuite/cargo_bench/no_keep_going/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_build/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_build/help/stdout.log index af906c24f..56b934cd1 100644 --- a/src/tools/cargo/tests/testsuite/cargo_build/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_build/help/stdout.log @@ -41,8 +41,8 @@ Compilation Options: -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) - --target Build for the target triple + --keep-going Do not abort the build as soon as there is an error + --target [] Build for the target triple --target-dir Directory for all generated artifacts --out-dir Copy final artifacts to this directory (unstable) --build-plan Output the build plan in JSON (unstable) diff --git a/src/tools/cargo/tests/testsuite/cargo_check/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_check/help/stdout.log index 7c87615cd..92d44a6de 100644 --- a/src/tools/cargo/tests/testsuite/cargo_check/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_check/help/stdout.log @@ -39,10 +39,10 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error -r, --release Check artifacts in release mode, with optimizations --profile Check artifacts with the specified profile - --target Check for the target triple + --target [] Check for the target triple --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_clean/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_clean/help/stdout.log index fd3c8855c..6e9e82772 100644 --- a/src/tools/cargo/tests/testsuite/cargo_clean/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_clean/help/stdout.log @@ -5,6 +5,7 @@ Usage: cargo[EXE] clean [OPTIONS] Options: --doc Whether or not to clean just the documentation directory -q, --quiet Do not print cargo log messages + -n, --dry-run Display what would be deleted without deleting anything -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never --config Override a configuration value @@ -17,7 +18,7 @@ Package Selection: Compilation Options: -r, --release Whether or not to clean release artifacts --profile Clean artifacts of the specified profile - --target Target triple to clean output for + --target [] Target triple to clean output for --target-dir Directory for all generated artifacts Manifest Options: diff --git a/src/tools/cargo/tests/testsuite/cargo_config/mod.rs b/src/tools/cargo/tests/testsuite/cargo_config/mod.rs index dc0a40ed8..c1769fb53 100644 --- a/src/tools/cargo/tests/testsuite/cargo_config/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_config/mod.rs @@ -84,7 +84,7 @@ fn get_toml() { alias.foo = \"abc --xyz\" alias.sub-example = [\"sub\", \"example\"] build.jobs = 99 -build.rustflags = [\"--flag-directory\", \"--flag-global\"] +build.rustflags = [\"--flag-global\", \"--flag-directory\"] extra-table.somekey = \"somevalue\" profile.dev.opt-level = 3 profile.dev.package.foo.opt-level = 1 @@ -111,7 +111,7 @@ target.\"cfg(target_os = \\\"linux\\\")\".runner = \"runme\" cargo_process("config get build.rustflags -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stdout("build.rustflags = [\"--flag-directory\", \"--flag-global\"]") + .with_stdout("build.rustflags = [\"--flag-global\", \"--flag-directory\"]") .with_stderr("") .run(); @@ -171,8 +171,8 @@ fn get_json() { "build": { "jobs": 99, "rustflags": [ - "--flag-directory", - "--flag-global" + "--flag-global", + "--flag-directory" ] }, "extra-table": { @@ -259,8 +259,8 @@ alias.sub-example = [ ] build.jobs = 99 # [ROOT]/home/.cargo/config.toml build.rustflags = [ - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml \"--flag-global\", # [ROOT]/home/.cargo/config.toml + \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml ] extra-table.somekey = \"somevalue\" # [ROOT]/home/.cargo/config.toml profile.dev.opt-level = 3 # [ROOT]/home/.cargo/config.toml @@ -280,8 +280,8 @@ target.\"cfg(target_os = \\\"linux\\\")\".runner = \"runme\" # [ROOT]/home/.carg .with_stdout( "\ build.rustflags = [ - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml \"--flag-global\", # [ROOT]/home/.cargo/config.toml + \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml \"env1\", # environment variable `CARGO_BUILD_RUSTFLAGS` \"env2\", # environment variable `CARGO_BUILD_RUSTFLAGS` ] @@ -310,12 +310,12 @@ fn show_origin_toml_cli() { .with_stdout( "\ build.rustflags = [ - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml \"--flag-global\", # [ROOT]/home/.cargo/config.toml - \"cli1\", # --config cli option - \"cli2\", # --config cli option + \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml \"env1\", # environment variable `CARGO_BUILD_RUSTFLAGS` \"env2\", # environment variable `CARGO_BUILD_RUSTFLAGS` + \"cli1\", # --config cli option + \"cli2\", # --config cli option ] ", ) @@ -471,7 +471,7 @@ fn includes() { cargo_process("config get build.rustflags -Zunstable-options -Zconfig-include") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config", "config-include"]) - .with_stdout(r#"build.rustflags = ["--flag-other", "--flag-directory", "--flag-global"]"#) + .with_stdout(r#"build.rustflags = ["--flag-global", "--flag-other", "--flag-directory"]"#) .with_stderr("") .run(); @@ -481,9 +481,9 @@ fn includes() { .with_stdout( "\ build.rustflags = [ + \"--flag-global\", # [ROOT]/home/.cargo/config.toml \"--flag-other\", # [ROOT]/foo/.cargo/other.toml \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml - \"--flag-global\", # [ROOT]/home/.cargo/config.toml ] ", ) diff --git a/src/tools/cargo/tests/testsuite/cargo_doc/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_doc/help/stdout.log index 480e189c1..8ff5f9b72 100644 --- a/src/tools/cargo/tests/testsuite/cargo_doc/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_doc/help/stdout.log @@ -36,10 +36,10 @@ Target Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_features.rs b/src/tools/cargo/tests/testsuite/cargo_features.rs index ed5f53a1e..cf7ef0190 100644 --- a/src/tools/cargo/tests/testsuite/cargo_features.rs +++ b/src/tools/cargo/tests/testsuite/cargo_features.rs @@ -676,8 +676,11 @@ fn wrong_position() { error: failed to parse manifest at [..] Caused by: - cargo-features = [\"test-dummy-unstable\"] was found in the wrong location: it \ - should be set at the top of Cargo.toml before any tables + TOML parse error at line 5, column 34 + | + 5 | cargo-features = [\"test-dummy-unstable\"] + | ^^^^^^^^^^^^^^^^^^^^^^^ + the field `cargo-features` should be set at the top of Cargo.toml before any tables ", ) .run(); diff --git a/src/tools/cargo/tests/testsuite/cargo_fetch/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_fetch/help/stdout.log index b9bd6c35b..32f29f1b3 100644 --- a/src/tools/cargo/tests/testsuite/cargo_fetch/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_fetch/help/stdout.log @@ -11,7 +11,7 @@ Options: -h, --help Print help Compilation Options: - --target Fetch dependencies for the target triple + --target [] Fetch dependencies for the target triple Manifest Options: --manifest-path Path to Cargo.toml diff --git a/src/tools/cargo/tests/testsuite/cargo_fix/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_fix/help/stdout.log index c0a98218a..dbbd11b77 100644 --- a/src/tools/cargo/tests/testsuite/cargo_fix/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_fix/help/stdout.log @@ -44,10 +44,10 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error -r, --release Fix artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - --target Fix for the target triple + --target [] Fix for the target triple --target-dir Directory for all generated artifacts --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/clean-glob b/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/clean-glob index a9d37c560..eb5a316cb 100644 --- a/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/clean-glob +++ b/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/clean-glob @@ -1,2 +1 @@ target -Cargo.lock diff --git a/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/ignore-glob b/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/ignore-glob index a9d37c560..eb5a316cb 100644 --- a/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/ignore-glob +++ b/src/tools/cargo/tests/testsuite/cargo_init/fossil_autodetect/out/.fossil-settings/ignore-glob @@ -1,2 +1 @@ target -Cargo.lock diff --git a/src/tools/cargo/tests/testsuite/cargo_init/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_init/help/stdout.log index 5dfb02498..0eb4c976b 100644 --- a/src/tools/cargo/tests/testsuite/cargo_init/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_init/help/stdout.log @@ -6,10 +6,9 @@ Arguments: [path] [default: .] Options: - --vcs Initialize a new repository for the given version control system (git, - hg, pijul, or fossil) or do not initialize any version control at all - (none), overriding a global configuration. [possible values: git, hg, - pijul, fossil, none] + --vcs Initialize a new repository for the given version control system, + overriding a global configuration. [possible values: git, hg, pijul, + fossil, none] --bin Use a binary (application) template [default] --lib Use a library template --edition Edition to set for the crate generated [possible values: 2015, 2018, diff --git a/src/tools/cargo/tests/testsuite/cargo_init/pijul_autodetect/out/.ignore b/src/tools/cargo/tests/testsuite/cargo_init/pijul_autodetect/out/.ignore index 4fffb2f89..ea8c4bf7f 100644 --- a/src/tools/cargo/tests/testsuite/cargo_init/pijul_autodetect/out/.ignore +++ b/src/tools/cargo/tests/testsuite/cargo_init/pijul_autodetect/out/.ignore @@ -1,2 +1 @@ /target -/Cargo.lock diff --git a/src/tools/cargo/tests/testsuite/cargo_install/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_install/help/stdout.log index a07fa47f6..2267c5f6b 100644 --- a/src/tools/cargo/tests/testsuite/cargo_install/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_install/help/stdout.log @@ -42,9 +42,9 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error --profile Install artifacts with the specified profile - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_login/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_login/help/stdout.log index faec55c18..fd0f3eb3d 100644 --- a/src/tools/cargo/tests/testsuite/cargo_login/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_login/help/stdout.log @@ -4,7 +4,7 @@ Usage: cargo[EXE] login [OPTIONS] [token] [-- [args]...] Arguments: [token] - [args]... Arguments for the credential provider (unstable) + [args]... Additional arguments for the credential provider Options: --registry Registry to use diff --git a/src/tools/cargo/tests/testsuite/cargo_new/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_new/help/stdout.log index 7252e0da1..a937f619b 100644 --- a/src/tools/cargo/tests/testsuite/cargo_new/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_new/help/stdout.log @@ -6,10 +6,9 @@ Arguments: Options: - --vcs Initialize a new repository for the given version control system (git, - hg, pijul, or fossil) or do not initialize any version control at all - (none), overriding a global configuration. [possible values: git, hg, - pijul, fossil, none] + --vcs Initialize a new repository for the given version control system, + overriding a global configuration. [possible values: git, hg, pijul, + fossil, none] --bin Use a binary (application) template [default] --lib Use a library template --edition Edition to set for the crate generated [possible values: 2015, 2018, diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs index 0b7697d20..9b9642468 100644 --- a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs @@ -1,7 +1,6 @@ use cargo_test_support::compare::assert_ui; use cargo_test_support::curr_dir; use cargo_test_support::CargoCommand; -use cargo_test_support::ChannelChanger; use cargo_test_support::Project; #[cargo_test] @@ -12,9 +11,8 @@ fn case() { snapbox::cmd::Command::cargo_ui() .arg("new") - .args(["crates/foo", "-Zlints"]) + .args(["crates/foo"]) .current_dir(cwd) - .masquerade_as_nightly_cargo(&["lints"]) .assert() .success() .stdout_matches_path(curr_dir!().join("stdout.log")) diff --git a/src/tools/cargo/tests/testsuite/cargo_new/mod.rs b/src/tools/cargo/tests/testsuite/cargo_new/mod.rs index 887316395..969b09f4f 100644 --- a/src/tools/cargo/tests/testsuite/cargo_new/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_new/mod.rs @@ -4,4 +4,4 @@ mod inherit_workspace_package_table; mod inherit_workspace_package_table_with_edition; mod inherit_workspace_package_table_with_registry; mod inherit_workspace_package_table_without_version; -mod not_inherit_workspace_package_table_if_not_memebers; +mod not_inherit_workspace_package_table_if_not_members; diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/Cargo.toml new file mode 100644 index 000000000..2d204581c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/Cargo.toml @@ -0,0 +1,15 @@ +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/README.md b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/in/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/mod.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/mod.rs new file mode 100644 index 000000000..cdddf0e64 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/mod.rs @@ -0,0 +1,22 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("new") + .args(["foo"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/Cargo.toml new file mode 100644 index 000000000..2d204581c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/Cargo.toml @@ -0,0 +1,15 @@ +[workspace.package] +authors = ["Rustaceans"] +description = "foo" +edition = "2018" +homepage = "foo" +keywords = ["foo", "bar"] +readme = "README.md" +rust-version = "1.67.0" +categories = ["algorithms"] +documentation = "foo" +exclude = ["foo"] +include = ["foo"] +license = "MIT OR Apache-2.0" +publish = false +repository = "foo" diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/Cargo.toml new file mode 100644 index 000000000..4fcf77121 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "foo" +version = "0.1.0" +authors.workspace = true +description.workspace = true +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +readme.workspace = true +rust-version.workspace = true +categories.workspace = true +documentation.workspace = true +exclude.workspace = true +include.workspace = true +license.workspace = true +publish.workspace = true +repository.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/src/main.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/foo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/src/lib.rs new file mode 100644 index 000000000..7d12d9af8 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/out/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stderr.log b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stderr.log new file mode 100644 index 000000000..03b1ff6db --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stderr.log @@ -0,0 +1,9 @@ +warning: compiling this new package may not work due to invalid workspace configuration + +current package believes it's in a workspace when it's not: +current: [ROOT]/case/foo/Cargo.toml +workspace: [ROOT]/case/Cargo.toml + +this may be fixable by adding `foo` to the `workspace.members` array of the manifest located at: [ROOT]/case/Cargo.toml +Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. + Created binary (application) `foo` package diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stdout.log b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_members/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml deleted file mode 100644 index 2d204581c..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[workspace.package] -authors = ["Rustaceans"] -description = "foo" -edition = "2018" -homepage = "foo" -keywords = ["foo", "bar"] -readme = "README.md" -rust-version = "1.67.0" -categories = ["algorithms"] -documentation = "foo" -exclude = ["foo"] -include = ["foo"] -license = "MIT OR Apache-2.0" -publish = false -repository = "foo" diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/README.md b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/README.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs deleted file mode 100644 index 7d12d9af8..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/in/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs deleted file mode 100644 index cdddf0e64..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -use cargo_test_support::compare::assert_ui; -use cargo_test_support::curr_dir; -use cargo_test_support::CargoCommand; -use cargo_test_support::Project; - -#[cargo_test] -fn case() { - let project = Project::from_template(curr_dir!().join("in")); - let project_root = project.root(); - let cwd = &project_root; - - snapbox::cmd::Command::cargo_ui() - .arg("new") - .args(["foo"]) - .current_dir(cwd) - .assert() - .success() - .stdout_matches_path(curr_dir!().join("stdout.log")) - .stderr_matches_path(curr_dir!().join("stderr.log")); - - assert_ui().subset_matches(curr_dir!().join("out"), &project_root); -} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml deleted file mode 100644 index 2d204581c..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[workspace.package] -authors = ["Rustaceans"] -description = "foo" -edition = "2018" -homepage = "foo" -keywords = ["foo", "bar"] -readme = "README.md" -rust-version = "1.67.0" -categories = ["algorithms"] -documentation = "foo" -exclude = ["foo"] -include = ["foo"] -license = "MIT OR Apache-2.0" -publish = false -repository = "foo" diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml deleted file mode 100644 index 4fcf77121..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "foo" -version = "0.1.0" -authors.workspace = true -description.workspace = true -edition.workspace = true -homepage.workspace = true -keywords.workspace = true -readme.workspace = true -rust-version.workspace = true -categories.workspace = true -documentation.workspace = true -exclude.workspace = true -include.workspace = true -license.workspace = true -publish.workspace = true -repository.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs deleted file mode 100644 index e7a11a969..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/foo/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs deleted file mode 100644 index 7d12d9af8..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/out/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } -} diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log deleted file mode 100644 index 03b1ff6db..000000000 --- a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stderr.log +++ /dev/null @@ -1,9 +0,0 @@ -warning: compiling this new package may not work due to invalid workspace configuration - -current package believes it's in a workspace when it's not: -current: [ROOT]/case/foo/Cargo.toml -workspace: [ROOT]/case/Cargo.toml - -this may be fixable by adding `foo` to the `workspace.members` array of the manifest located at: [ROOT]/case/Cargo.toml -Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest. - Created binary (application) `foo` package diff --git a/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stdout.log b/src/tools/cargo/tests/testsuite/cargo_new/not_inherit_workspace_package_table_if_not_memebers/stdout.log deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/tools/cargo/tests/testsuite/cargo_owner/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_owner/help/stdout.log index 3c8495ff0..580be3c88 100644 --- a/src/tools/cargo/tests/testsuite/cargo_owner/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_owner/help/stdout.log @@ -9,9 +9,9 @@ Options: -a, --add Name of a user or team to invite as an owner -r, --remove Name of a user or team to remove as an owner -l, --list List owners of a crate - --index Registry index to modify owners for + --index Registry index URL to modify owners for + --registry Registry to modify owners for --token API token to use when authenticating - --registry Registry to use -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never diff --git a/src/tools/cargo/tests/testsuite/cargo_package/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_package/help/stdout.log index 35e32f313..5079c2a6f 100644 --- a/src/tools/cargo/tests/testsuite/cargo_package/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_package/help/stdout.log @@ -25,10 +25,10 @@ Feature Selection: --no-default-features Do not activate the `default` feature Compilation Options: - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error Manifest Options: --manifest-path Path to Cargo.toml diff --git a/src/tools/cargo/tests/testsuite/cargo_publish/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_publish/help/stdout.log index c02522887..df2594fb4 100644 --- a/src/tools/cargo/tests/testsuite/cargo_publish/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_publish/help/stdout.log @@ -3,9 +3,9 @@ Upload a package to the registry Usage: cargo[EXE] publish [OPTIONS] Options: - --dry-run Perform all checks without uploading + -n, --dry-run Perform all checks without uploading --index Registry index URL to upload the package to - --registry Registry to publish to + --registry Registry to upload the package to --token Token to use when uploading --no-verify Don't verify the contents by building them --allow-dirty Allow dirty working directories to be packaged @@ -26,8 +26,8 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) - --target Build for the target triple + --keep-going Do not abort the build as soon as there is an error + --target [] Build for the target triple --target-dir Directory for all generated artifacts Manifest Options: diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_remove/help/stdout.log index 81a2d78b6..8937fb9f3 100644 --- a/src/tools/cargo/tests/testsuite/cargo_remove/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_remove/help/stdout.log @@ -6,7 +6,7 @@ Arguments: ... Dependencies to be removed Options: - --dry-run Don't actually write the manifest + -n, --dry-run Don't actually write the manifest -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never @@ -27,3 +27,5 @@ Manifest Options: --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date --offline Run without accessing the network + +Run `cargo help remove` for more detailed information. diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs index ea7902bd8..4403e2425 100644 --- a/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs @@ -23,6 +23,7 @@ mod optional_dep_feature; mod optional_feature; mod package; mod remove_basic; +mod skip_gc_glob_profile; mod target; mod target_build; mod target_dev; diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/Cargo.toml new file mode 100644 index 000000000..a25e33ae0 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[dependencies] +toml = "0.1" + +[profile.dev.package."*"] +opt-level = 3 \ No newline at end of file diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/in/src/lib.rs @@ -0,0 +1 @@ + diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/mod.rs new file mode 100644 index 000000000..2d587455c --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + cargo_test_support::registry::init(); + cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish(); + + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["toml"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/out/Cargo.toml new file mode 100644 index 000000000..76e3bcf77 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/out/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[profile.dev.package."*"] +opt-level = 3 diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stderr.log b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stderr.log new file mode 100644 index 000000000..9dee9e2b7 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stderr.log @@ -0,0 +1 @@ + Removing toml from dependencies diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stdout.log b/src/tools/cargo/tests/testsuite/cargo_remove/skip_gc_glob_profile/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_run/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_run/help/stdout.log index 6ab0e76b1..4b39f30b3 100644 --- a/src/tools/cargo/tests/testsuite/cargo_run/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_run/help/stdout.log @@ -30,10 +30,10 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_rustc/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_rustc/help/stdout.log index f587c3276..9d43841fe 100644 --- a/src/tools/cargo/tests/testsuite/cargo_rustc/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_rustc/help/stdout.log @@ -41,10 +41,10 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - --target Target triple which compiles will be for + --target [] Target triple which compiles will be for --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_rustdoc/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_rustdoc/help/stdout.log index 4cac29e0a..706072f24 100644 --- a/src/tools/cargo/tests/testsuite/cargo_rustdoc/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_rustdoc/help/stdout.log @@ -39,10 +39,10 @@ Feature Selection: Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. - --keep-going Do not abort the build as soon as there is an error (unstable) + --keep-going Do not abort the build as soon as there is an error -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_search/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_search/help/stdout.log index 8572064e3..07170ad70 100644 --- a/src/tools/cargo/tests/testsuite/cargo_search/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_search/help/stdout.log @@ -7,8 +7,8 @@ Arguments: Options: --limit Limit the number of results (default: 10, max: 100) - --index Registry index URL to upload the package to - --registry Registry to use + --index Registry index URL to search packages in + --registry Registry to search packages in -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never diff --git a/src/tools/cargo/tests/testsuite/cargo_test/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_test/help/stdout.log index d693dc3c9..5df62d6bb 100644 --- a/src/tools/cargo/tests/testsuite/cargo_test/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_test/help/stdout.log @@ -48,7 +48,7 @@ Compilation Options: -j, --jobs Number of parallel jobs, defaults to # of CPUs. -r, --release Build artifacts in release mode, with optimizations --profile Build artifacts with the specified profile - --target Build for the target triple + --target [] Build for the target triple --target-dir Directory for all generated artifacts --unit-graph Output build graph in JSON (unstable) --timings[=] Timing output formats (unstable) (comma separated): html, json diff --git a/src/tools/cargo/tests/testsuite/cargo_test/mod.rs b/src/tools/cargo/tests/testsuite/cargo_test/mod.rs index c0ce11180..28be9d1a7 100644 --- a/src/tools/cargo/tests/testsuite/cargo_test/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_test/mod.rs @@ -1 +1,2 @@ mod help; +mod no_keep_going; diff --git a/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/Cargo.toml new file mode 100644 index 000000000..c35d63273 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/Cargo.toml @@ -0,0 +1,3 @@ +[package] +name = "foo" +version = "0.1.0" diff --git a/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/in/src/lib.rs new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/mod.rs b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/mod.rs new file mode 100644 index 000000000..fdec61642 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/mod.rs @@ -0,0 +1,19 @@ +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("test") + .arg("--keep-going") + .current_dir(cwd) + .assert() + .code(1) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stderr.log b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stderr.log new file mode 100644 index 000000000..fd4ca9b2a --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stderr.log @@ -0,0 +1,7 @@ +error: unexpected argument '--keep-going' found + + tip: use `--no-fail-fast` to run as many tests as possible regardless of failure + +Usage: cargo[EXE] test [OPTIONS] [TESTNAME] [-- [args]...] + +For more information, try '--help'. diff --git a/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stdout.log b/src/tools/cargo/tests/testsuite/cargo_test/no_keep_going/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_tree/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_tree/help/stdout.log index 268b6b2ad..4170583a8 100644 --- a/src/tools/cargo/tests/testsuite/cargo_tree/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_tree/help/stdout.log @@ -33,8 +33,8 @@ Feature Selection: --no-default-features Do not activate the `default` feature Compilation Options: - --target Filter dependencies matching the given target-triple (default host - platform). Pass `all` to include all targets. + --target [] Filter dependencies matching the given target-triple (default host + platform). Pass `all` to include all targets. Manifest Options: --manifest-path Path to Cargo.toml diff --git a/src/tools/cargo/tests/testsuite/cargo_update/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_update/help/stdout.log index 6cc109151..92caeb656 100644 --- a/src/tools/cargo/tests/testsuite/cargo_update/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_update/help/stdout.log @@ -1,11 +1,11 @@ Update dependencies as recorded in the local lock file -Usage: cargo[EXE] update [OPTIONS] +Usage: cargo[EXE] update [OPTIONS] [SPEC]... Options: - --dry-run Don't actually write the lockfile - --aggressive Force updating all dependencies of SPEC as well when used with -p - --precise Update a single dependency to exactly PRECISE when used with -p + -n, --dry-run Don't actually write the lockfile + --recursive Force updating all dependencies of [SPEC]... as well + --precise Update [SPEC] to exactly PRECISE -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) --color Coloring: auto, always, never @@ -14,8 +14,8 @@ Options: -h, --help Print help Package Selection: - -w, --workspace Only update the workspace packages - -p, --package [] Package to update + -w, --workspace Only update the workspace packages + [SPEC]... Package to update Manifest Options: --manifest-path Path to Cargo.toml diff --git a/src/tools/cargo/tests/testsuite/cargo_update/mod.rs b/src/tools/cargo/tests/testsuite/cargo_update/mod.rs index c0ce11180..a809d9fe9 100644 --- a/src/tools/cargo/tests/testsuite/cargo_update/mod.rs +++ b/src/tools/cargo/tests/testsuite/cargo_update/mod.rs @@ -1 +1,2 @@ mod help; +mod toolchain_pkgname; diff --git a/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/Cargo.toml new file mode 100644 index 000000000..c844631b2 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/Cargo.toml @@ -0,0 +1,5 @@ +[package] +name = "test" +version = "0.1.0" + +[dependencies] diff --git a/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/src/main.rs b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/in/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/mod.rs b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/mod.rs new file mode 100644 index 000000000..f1488b90d --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/mod.rs @@ -0,0 +1,19 @@ +use cargo_test_support::curr_dir; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("update") + .arg("+stable") + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); +} diff --git a/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stderr.log b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stderr.log new file mode 100644 index 000000000..7e5870c54 --- /dev/null +++ b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stderr.log @@ -0,0 +1,2 @@ +error: invalid character `+` in package name: `+stable` + Use `cargo +stable update` if you meant to use the `stable` toolchain. diff --git a/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stdout.log b/src/tools/cargo/tests/testsuite/cargo_update/toolchain_pkgname/stdout.log new file mode 100644 index 000000000..e69de29bb diff --git a/src/tools/cargo/tests/testsuite/cargo_yank/help/stdout.log b/src/tools/cargo/tests/testsuite/cargo_yank/help/stdout.log index 25b04e6c7..c6dbfeb9d 100644 --- a/src/tools/cargo/tests/testsuite/cargo_yank/help/stdout.log +++ b/src/tools/cargo/tests/testsuite/cargo_yank/help/stdout.log @@ -8,8 +8,8 @@ Arguments: Options: --version The version to yank or un-yank --undo Undo a yank, putting a version back into the index - --index Registry index to yank from - --registry Registry to use + --index Registry index URL to yank from + --registry Registry to yank from --token API token to use when authenticating -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) diff --git a/src/tools/cargo/tests/testsuite/check.rs b/src/tools/cargo/tests/testsuite/check.rs index 7bc9a38a3..b74bd6209 100644 --- a/src/tools/cargo/tests/testsuite/check.rs +++ b/src/tools/cargo/tests/testsuite/check.rs @@ -861,8 +861,7 @@ fn check_keep_going() { .build(); // Due to -j1, without --keep-going only one of the two bins would be built. - foo.cargo("check -j1 --keep-going -Zunstable-options") - .masquerade_as_nightly_cargo(&["keep-going"]) + foo.cargo("check -j1 --keep-going") .with_status(101) .with_stderr_contains("error: ONE") .with_stderr_contains("error: TWO") diff --git a/src/tools/cargo/tests/testsuite/clean.rs b/src/tools/cargo/tests/testsuite/clean.rs index e0885fd26..fbb4d3e5b 100644 --- a/src/tools/cargo/tests/testsuite/clean.rs +++ b/src/tools/cargo/tests/testsuite/clean.rs @@ -272,7 +272,7 @@ fn clean_doc() { assert!(doc_path.is_dir()); - p.cargo("clean --doc").run(); + p.cargo("clean --doc").with_stderr("[REMOVED] [..]").run(); assert!(!doc_path.is_dir()); assert!(p.build_dir().is_dir()); @@ -414,9 +414,10 @@ fn clean_verbose() { if cfg!(target_os = "macos") { // Rust 1.69 has changed so that split-debuginfo=unpacked includes unpacked for rlibs. for obj in p.glob("target/debug/deps/bar-*.o") { - expected.push_str(&format!("[REMOVING] [..]{}", obj.unwrap().display())); + expected.push_str(&format!("[REMOVING] [..]{}\n", obj.unwrap().display())); } } + expected.push_str("[REMOVED] [..] files, [..] total\n"); p.cargo("clean -p bar --verbose") .with_stderr_unordered(&expected) .run(); @@ -569,10 +570,120 @@ fn assert_all_clean(build_dir: &Path) { } #[cargo_test] -fn clean_spec_multiple() { +fn clean_spec_version() { // clean -p foo where foo matches multiple versions - Package::new("bar", "1.0.0").publish(); - Package::new("bar", "2.0.0").publish(); + Package::new("bar", "0.1.0").publish(); + Package::new("bar", "0.2.0").publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar1 = {version="0.1", package="bar"} + bar2 = {version="0.2", package="bar"} + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build").run(); + + // Check suggestion for bad pkgid. + p.cargo("clean -p baz") + .with_status(101) + .with_stderr( + "\ +error: package ID specification `baz` did not match any packages + +Did you mean `bar`? +", + ) + .run(); + + p.cargo("clean -p bar:0.1.0") + .with_stderr( + "warning: version qualifier in `-p bar:0.1.0` is ignored, \ + cleaning all versions of `bar` found\n\ + [REMOVED] [..] files, [..] total", + ) + .run(); + let mut walker = walkdir::WalkDir::new(p.build_dir()) + .into_iter() + .filter_map(|e| e.ok()) + .filter(|e| { + let n = e.file_name().to_str().unwrap(); + n.starts_with("bar") || n.starts_with("libbar") + }); + if let Some(e) = walker.next() { + panic!("{:?} was not cleaned", e.path()); + } +} + +#[cargo_test] +fn clean_spec_partial_version() { + // clean -p foo where foo matches multiple versions + Package::new("bar", "0.1.0").publish(); + Package::new("bar", "0.2.0").publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar1 = {version="0.1", package="bar"} + bar2 = {version="0.2", package="bar"} + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("build").run(); + + // Check suggestion for bad pkgid. + p.cargo("clean -p baz") + .with_status(101) + .with_stderr( + "\ +error: package ID specification `baz` did not match any packages + +Did you mean `bar`? +", + ) + .run(); + + p.cargo("clean -p bar:0.1") + .with_stderr( + "warning: version qualifier in `-p bar:0.1` is ignored, \ + cleaning all versions of `bar` found\n\ + [REMOVED] [..] files, [..] total", + ) + .run(); + let mut walker = walkdir::WalkDir::new(p.build_dir()) + .into_iter() + .filter_map(|e| e.ok()) + .filter(|e| { + let n = e.file_name().to_str().unwrap(); + n.starts_with("bar") || n.starts_with("libbar") + }); + if let Some(e) = walker.next() { + panic!("{:?} was not cleaned", e.path()); + } +} + +#[cargo_test] +fn clean_spec_partial_version_ambiguous() { + // clean -p foo where foo matches multiple versions + Package::new("bar", "0.1.0").publish(); + Package::new("bar", "0.2.0").publish(); let p = project() .file( @@ -583,8 +694,8 @@ fn clean_spec_multiple() { version = "0.1.0" [dependencies] - bar1 = {version="1.0", package="bar"} - bar2 = {version="2.0", package="bar"} + bar1 = {version="0.1", package="bar"} + bar2 = {version="0.2", package="bar"} "#, ) .file("src/lib.rs", "") @@ -604,10 +715,11 @@ error: package ID specification `baz` did not match any packages ) .run(); - p.cargo("clean -p bar:1.0.0") + p.cargo("clean -p bar:0") .with_stderr( - "warning: version qualifier in `-p bar:1.0.0` is ignored, \ - cleaning all versions of `bar` found", + "warning: version qualifier in `-p bar:0` is ignored, \ + cleaning all versions of `bar` found\n\ + [REMOVED] [..] files, [..] total", ) .run(); let mut walker = walkdir::WalkDir::new(p.build_dir()) @@ -673,3 +785,72 @@ fn clean_spec_reserved() { ) .run(); } + +#[cargo_test] +fn clean_dry_run() { + // Basic `clean --dry-run` test. + Package::new("bar", "1.0.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = "1.0" + "#, + ) + .file("src/lib.rs", "") + .build(); + + let ls_r = || -> Vec<_> { + let mut file_list: Vec<_> = walkdir::WalkDir::new(p.build_dir()) + .into_iter() + .filter_map(|e| e.map(|e| e.path().to_owned()).ok()) + .collect(); + file_list.sort(); + file_list + }; + + // Start with no files. + p.cargo("clean --dry-run") + .with_stdout("") + .with_stderr( + "[SUMMARY] 0 files\n\ + [WARNING] no files deleted due to --dry-run", + ) + .run(); + p.cargo("check").run(); + let before = ls_r(); + p.cargo("clean --dry-run") + .with_stderr( + "[SUMMARY] [..] files, [..] total\n\ + [WARNING] no files deleted due to --dry-run", + ) + .run(); + // Verify it didn't delete anything. + let after = ls_r(); + assert_eq!(before, after); + let expected = cargo::util::iter_join(before.iter().map(|p| p.to_str().unwrap()), "\n"); + eprintln!("{expected}"); + // Verify the verbose output. + p.cargo("clean --dry-run -v") + .with_stdout_unordered(expected) + .with_stderr( + "[SUMMARY] [..] files, [..] total\n\ + [WARNING] no files deleted due to --dry-run", + ) + .run(); +} + +#[cargo_test] +fn doc_with_package_selection() { + // --doc with -p + let p = project().file("src/lib.rs", "").build(); + p.cargo("clean --doc -p foo") + .with_status(101) + .with_stderr("error: --doc cannot be used with -p") + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/config.rs b/src/tools/cargo/tests/testsuite/config.rs index 5d4163818..7078fc445 100644 --- a/src/tools/cargo/tests/testsuite/config.rs +++ b/src/tools/cargo/tests/testsuite/config.rs @@ -541,18 +541,18 @@ expected boolean, but found array", config.get::("b").unwrap(), VSOB::VecString(vec![ "b".to_string(), - "clib".to_string(), "env1".to_string(), - "env2".to_string() + "env2".to_string(), + "clib".to_string(), ]) ); assert_eq!( config.get::("c").unwrap(), VSOB::VecString(vec![ "c".to_string(), - "clic".to_string(), "e1".to_string(), - "e2".to_string() + "e2".to_string(), + "clic".to_string(), ]) ); } @@ -721,9 +721,6 @@ could not load Cargo configuration Caused by: could not parse TOML configuration in `[..]/.cargo/config` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 1, column 5 | @@ -1090,9 +1087,6 @@ could not load Cargo configuration Caused by: could not parse TOML configuration in `[..]/.cargo/config` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 3, column 1 | @@ -1582,12 +1576,12 @@ known-hosts = [ .as_ref() .unwrap(); assert_eq!(kh.len(), 4); - assert_eq!(kh[0].val, "example.org ..."); - assert_eq!(kh[0].definition, Definition::Path(foo_path.clone())); - assert_eq!(kh[1].val, "example.com ..."); + assert_eq!(kh[0].val, "example.com ..."); + assert_eq!(kh[0].definition, Definition::Path(root_path.clone())); + assert_eq!(kh[1].val, "example.net ..."); assert_eq!(kh[1].definition, Definition::Path(root_path.clone())); - assert_eq!(kh[2].val, "example.net ..."); - assert_eq!(kh[2].definition, Definition::Path(root_path.clone())); + assert_eq!(kh[2].val, "example.org ..."); + assert_eq!(kh[2].definition, Definition::Path(foo_path.clone())); assert_eq!(kh[3].val, "env-example"); assert_eq!( kh[3].definition, diff --git a/src/tools/cargo/tests/testsuite/config_cli.rs b/src/tools/cargo/tests/testsuite/config_cli.rs index 1120e279d..67aca0d19 100644 --- a/src/tools/cargo/tests/testsuite/config_cli.rs +++ b/src/tools/cargo/tests/testsuite/config_cli.rs @@ -143,11 +143,9 @@ fn merges_array() { .env("CARGO_BUILD_RUSTFLAGS", "--env1 --env2") .config_arg("build.rustflags = ['--cli']") .build(); - // The order of cli/env is a little questionable here, but would require - // much more complex merging logic. assert_eq!( config.get::>("build.rustflags").unwrap(), - ["--file", "--cli", "--env1", "--env2"] + ["--file", "--env1", "--env2", "--cli"] ); // With advanced-env. @@ -158,7 +156,7 @@ fn merges_array() { .build(); assert_eq!( config.get::>("build.rustflags").unwrap(), - ["--file", "--cli", "--env"] + ["--file", "--env", "--cli"] ); // Merges multiple instances. @@ -202,7 +200,7 @@ fn string_list_array() { .get::("build.rustflags") .unwrap() .as_slice(), - ["--file", "--cli", "--env1", "--env2"] + ["--file", "--env1", "--env2", "--cli"] ); // With advanced-env. @@ -216,7 +214,7 @@ fn string_list_array() { .get::("build.rustflags") .unwrap() .as_slice(), - ["--file", "--cli", "--env"] + ["--file", "--env", "--cli"] ); } diff --git a/src/tools/cargo/tests/testsuite/credential_process.rs b/src/tools/cargo/tests/testsuite/credential_process.rs index c010c01cd..815089f70 100644 --- a/src/tools/cargo/tests/testsuite/credential_process.rs +++ b/src/tools/cargo/tests/testsuite/credential_process.rs @@ -7,63 +7,6 @@ fn toml_bin(proj: &Project, name: &str) -> String { proj.bin(name).display().to_string().replace('\\', "\\\\") } -#[cargo_test] -fn gated() { - let _alternative = registry::RegistryBuilder::new() - .alternative() - .no_configure_token() - .build(); - - let cratesio = registry::RegistryBuilder::new() - .no_configure_token() - .build(); - - let p = project() - .file( - ".cargo/config", - r#" - [registry] - credential-provider = ["false"] - "#, - ) - .file("Cargo.toml", &basic_manifest("foo", "1.0.0")) - .file("src/lib.rs", "") - .build(); - - p.cargo("publish --no-verify") - .replace_crates_io(cratesio.index_url()) - .masquerade_as_nightly_cargo(&["credential-process"]) - .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[ERROR] no token found, please run `cargo login` -or use environment variable CARGO_REGISTRY_TOKEN -", - ) - .run(); - - p.change_file( - ".cargo/config", - r#" - [registry.alternative] - credential-process = "false" - "#, - ); - - p.cargo("publish --no-verify --registry alternative") - .masquerade_as_nightly_cargo(&["credential-process"]) - .with_status(101) - .with_stderr( - "\ -[UPDATING] [..] -[ERROR] no token found for `alternative`, please run `cargo login --registry alternative` -or use environment variable CARGO_REGISTRIES_ALTERNATIVE_TOKEN -", - ) - .run(); -} - /// Setup for a test that will issue a command that needs to fetch a token. /// /// This does the following: @@ -125,14 +68,13 @@ fn publish() { // Checks that credential-process is used for `cargo publish`. let (p, _t) = get_token_test(); - p.cargo("publish --no-verify --registry alternative -Z credential-process -Z registry-auth") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("publish --no-verify --registry alternative") .with_stderr( r#"[UPDATING] [..] -{"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read"} [PACKAGING] foo v0.1.0 [..] [PACKAGED] [..] -{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.0","cksum":"[..]","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.0","cksum":"[..]"} [UPLOADING] foo v0.1.0 [..] [UPLOADED] foo v0.1.0 [..] note: Waiting [..] @@ -151,9 +93,8 @@ fn basic_unsupported() { .credential_provider(&["cargo:token-from-stdout", "false"]) .build(); - cargo_process("login -Z credential-process abcdefg") + cargo_process("login abcdefg") .replace_crates_io(registry.index_url()) - .masquerade_as_nightly_cargo(&["credential-process"]) .with_status(101) .with_stderr( "\ @@ -166,9 +107,8 @@ Caused by: ) .run(); - cargo_process("logout -Z credential-process") + cargo_process("logout") .replace_crates_io(registry.index_url()) - .masquerade_as_nightly_cargo(&["credential-process"]) .with_status(101) .with_stderr( "\ @@ -192,8 +132,7 @@ fn login() { ]) .build(); - cargo_process("login -Z credential-process abcdefg -- cmd3 --cmd4") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login abcdefg -- cmd3 --cmd4") .replace_crates_io(registry.index_url()) .with_stderr( r#"[UPDATING] [..] @@ -213,11 +152,10 @@ fn logout() { )]) .build(); - cargo_process("logout -Z credential-process") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("logout") .replace_crates_io(server.index_url()) .with_stderr( - r#"{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"logout","args":[]} + r#"{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"logout"} "#, ) .run(); @@ -227,12 +165,11 @@ fn logout() { fn yank() { let (p, _t) = get_token_test(); - p.cargo("yank --version 0.1.0 --registry alternative -Zcredential-process -Zregistry-auth") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("yank --version 0.1.0 --registry alternative") .with_stderr( r#"[UPDATING] [..] -{"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read","args":[]} -{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"yank","name":"foo","vers":"0.1.0","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read"} +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"yank","name":"foo","vers":"0.1.0"} [YANK] foo@0.1.0 "#, ) @@ -243,12 +180,11 @@ fn yank() { fn owner() { let (p, _t) = get_token_test(); - p.cargo("owner --add username --registry alternative -Zcredential-process -Zregistry-auth") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("owner --add username --registry alternative") .with_stderr( r#"[UPDATING] [..] -{"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read","args":[]} -{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"owners","name":"foo","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"alternative","headers":[..]},"kind":"get","operation":"read"} +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"owners","name":"foo"} [OWNER] completed! "#, ) @@ -278,8 +214,7 @@ fn invalid_token_output() { .file("src/lib.rs", "") .build(); - p.cargo("publish --no-verify --registry alternative -Z credential-process") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("publish --no-verify --registry alternative") .with_status(101) .with_stderr( "\ @@ -320,6 +255,35 @@ fn build_provider(name: &str, response: &str) -> String { toml_bin(&cred_proj, name) } +#[cargo_test] +fn not_found() { + let registry = registry::RegistryBuilder::new() + .no_configure_token() + .http_index() + .auth_required() + .credential_provider(&[&build_provider( + "not_found", + r#"{"Err": {"kind": "not-found"}}"#, + )]) + .build(); + + // should not suggest a _TOKEN environment variable since the cargo:token provider isn't available. + cargo_process("install -v foo") + .replace_crates_io(registry.index_url()) + .with_status(101) + .with_stderr( + r#"[UPDATING] [..] +[CREDENTIAL] [..]not_found[..] get crates-io +{"v":1[..] +[ERROR] failed to query replaced source registry `crates-io` + +Caused by: + no token found, please run `cargo login` +"#, + ) + .run(); +} + #[cargo_test] fn all_not_found() { let server = registry::RegistryBuilder::new() @@ -342,19 +306,18 @@ fn all_not_found() { ) .unwrap(); - cargo_process("install -v foo -Zcredential-process -Zregistry-auth") - .masquerade_as_nightly_cargo(&["credential-process", "registry-auth"]) + // should not suggest a _TOKEN environment variable since the cargo:token provider isn't available. + cargo_process("install -v foo") .replace_crates_io(server.index_url()) .with_status(101) .with_stderr( r#"[UPDATING] [..] [CREDENTIAL] [..]not_found[..] get crates-io -{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=\"https://test-registry-login/me\""[..]]},"kind":"get","operation":"read","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=\"https://test-registry-login/me\""[..]]},"kind":"get","operation":"read"} [ERROR] failed to query replaced source registry `crates-io` Caused by: no token found, please run `cargo login` - or use environment variable CARGO_REGISTRY_TOKEN "#, ) .run(); @@ -383,14 +346,13 @@ fn all_not_supported() { ) .unwrap(); - cargo_process("install -v foo -Zcredential-process -Zregistry-auth") - .masquerade_as_nightly_cargo(&["credential-process", "registry-auth"]) + cargo_process("install -v foo") .replace_crates_io(server.index_url()) .with_status(101) .with_stderr( r#"[UPDATING] [..] [CREDENTIAL] [..]not_supported[..] get crates-io -{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=\"https://test-registry-login/me\""[..]]},"kind":"get","operation":"read","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"crates-io","headers":[[..]"WWW-Authenticate: Cargo login_url=\"https://test-registry-login/me\""[..]]},"kind":"get","operation":"read"} [ERROR] failed to query replaced source registry `crates-io` Caused by: @@ -431,15 +393,14 @@ fn multiple_providers() { ) .unwrap(); - cargo_process("login -Z credential-process -v abcdefg") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -v abcdefg") .replace_crates_io(server.index_url()) .with_stderr( r#"[UPDATING] [..] [CREDENTIAL] [..]url_not_supported[..] login crates-io -{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]","args":[]} +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]"} [CREDENTIAL] [..]success_provider[..] login crates-io -{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]","args":[]} +{"v":1,"registry":{"index-url":"https://github.com/rust-lang/crates.io-index","name":"crates-io"},"kind":"login","token":"abcdefg","login-url":"[..]"} "#, ) .run(); @@ -447,25 +408,42 @@ fn multiple_providers() { #[cargo_test] fn both_token_and_provider() { + let server = registry::RegistryBuilder::new() + .credential_provider(&["cargo:paseto"]) + .build(); + + cargo_process("login -Z asymmetric-token") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) + .replace_crates_io(server.index_url()) + .with_stderr( + r#"[UPDATING] [..] +[WARNING] registry `crates-io` has a token configured in [..] that will be ignored because this registry is configured to use credential-provider `cargo:paseto` +k3.public[..] +"#, + ) + .run(); +} + +#[cargo_test] +fn registry_provider_overrides_global() { let server = registry::RegistryBuilder::new().build(); cargo_util::paths::append( &paths::home().join(".cargo/config"), format!( r#" [registry] - credential-provider = ["cargo:token"] + global-credential-providers = ["should-not-be-called"] "#, ) .as_bytes(), ) .unwrap(); - cargo_process("login -Z credential-process -v abcdefg") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -v abcdefg") + .env("CARGO_REGISTRY_CREDENTIAL_PROVIDER", "cargo:token") .replace_crates_io(server.index_url()) .with_stderr( r#"[UPDATING] [..] -[WARNING] registry `crates-io` has a token configured in [..]credentials.toml that will be ignored because a credential-provider is configured for this registry` [CREDENTIAL] cargo:token login crates-io [LOGIN] token for `crates-io` saved "#, @@ -492,8 +470,8 @@ fn both_asymmetric_and_token() { ) .unwrap(); - cargo_process("login -Z credential-process -v abcdefg") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -Zasymmetric-token -v abcdefg") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(server.index_url()) .with_stderr( r#"[UPDATING] [..] @@ -520,13 +498,13 @@ fn token_caching() { // Token should not be re-used if it is expired let expired_provider = build_provider( - "test-cred", - r#"{"Ok":{"kind":"get","token":"sekrit","cache":{"expires":0},"operation_independent":true}}"#, + "expired_provider", + r#"{"Ok":{"kind":"get","token":"sekrit","cache":"expires","expiration":0,"operation_independent":true}}"#, ); // Token should not be re-used for a different operation if it is not operation_independent let non_independent_provider = build_provider( - "test-cred", + "non_independent_provider", r#"{"Ok":{"kind":"get","token":"sekrit","cache":"session","operation_independent":false}}"#, ); @@ -557,10 +535,10 @@ fn token_caching() { .build(); let output = r#"[UPDATING] `alternative` index -{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"read","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"read"} [PACKAGING] foo v0.1.0 [..] [PACKAGED] [..] -{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.0","cksum":"[..]","args":[]} +{"v":1,"registry":{"index-url":"[..]","name":"alternative"},"kind":"get","operation":"publish","name":"foo","vers":"0.1.0","cksum":"[..]"} [UPLOADING] foo v0.1.0 [..] [UPLOADED] foo v0.1.0 [..] note: Waiting [..] @@ -568,11 +546,10 @@ You may press ctrl-c [..] [PUBLISHED] foo v0.1.0 [..] "#; - // The output should contain two JSON messages from the provider in boths cases: + // The output should contain two JSON messages from the provider in both cases: // The first because the credential is expired, the second because the provider // indicated that the token was non-operation-independent. - p.cargo("publish -Z credential-process --registry alternative --no-verify") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("publish --registry alternative --no-verify") .with_stderr(output) .run(); @@ -588,8 +565,7 @@ You may press ctrl-c [..] ), ); - p.cargo("publish -Z credential-process --registry alternative --no-verify") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("publish --registry alternative --no-verify") .with_stderr(output) .run(); } @@ -639,8 +615,7 @@ fn basic_provider() { .build(); Package::new("bar", "0.0.1").alternative(true).publish(); - p.cargo("check -Z credential-process -Z registry-auth") - .masquerade_as_nightly_cargo(&["credential-process", "registry-auth"]) + p.cargo("check") .with_stderr( "\ [UPDATING] `alternative` index @@ -656,3 +631,72 @@ CARGO_REGISTRY_INDEX_URL=Some([..]) ) .run(); } + +#[cargo_test] +fn unsupported_version() { + let cred_proj = project() + .at("new-vers") + .file("Cargo.toml", &basic_manifest("new-vers", "1.0.0")) + .file( + "src/main.rs", + &r####" + fn main() { + println!(r#"{{"v":[998, 999]}}"#); + assert_eq!(std::env::args().skip(1).next().unwrap(), "--cargo-plugin"); + let mut buffer = String::new(); + std::io::stdin().read_line(&mut buffer).unwrap(); + std::thread::sleep(std::time::Duration::from_secs(1)); + panic!("child process should have been killed before getting here"); + } "####, + ) + .build(); + cred_proj.cargo("build").run(); + let provider = toml_bin(&cred_proj, "new-vers"); + + let registry = registry::RegistryBuilder::new() + .no_configure_token() + .credential_provider(&[&provider]) + .build(); + + cargo_process("login abcdefg") + .replace_crates_io(registry.index_url()) + .with_status(101) + .with_stderr( + r#"[UPDATING] [..] +[ERROR] credential provider `[..]` failed action `login` + +Caused by: + credential provider supports protocol versions [998, 999], while Cargo supports [1] +"#, + ) + .run(); +} + +#[cargo_test] +fn alias_builtin_warning() { + let registry = registry::RegistryBuilder::new() + .credential_provider(&[&"cargo:token"]) + .build(); + + cargo_util::paths::append( + &paths::home().join(".cargo/config"), + format!( + r#" + [credential-alias] + "cargo:token" = ["ignored"] + "#, + ) + .as_bytes(), + ) + .unwrap(); + + cargo_process("login abcdefg") + .replace_crates_io(registry.index_url()) + .with_stderr( + r#"[UPDATING] [..] +[WARNING] credential-alias `cargo:token` (defined in `[..]`) will be ignored because it would shadow a built-in credential-provider +[LOGIN] token for `crates-io` saved +"#, + ) + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/doc.rs b/src/tools/cargo/tests/testsuite/doc.rs index 481df8590..a16980912 100644 --- a/src/tools/cargo/tests/testsuite/doc.rs +++ b/src/tools/cargo/tests/testsuite/doc.rs @@ -2004,7 +2004,7 @@ fn crate_versions() { let output_path = p.root().join("target/doc/foo/index.html"); let output_documentation = fs::read_to_string(&output_path).unwrap(); - assert!(output_documentation.contains("Version 1.2.4")); + assert!(output_documentation.contains("1.2.4")); } #[cargo_test] @@ -2028,7 +2028,7 @@ fn crate_versions_flag_is_overridden() { }; let asserts = |html: String| { assert!(!html.contains("1.2.4")); - assert!(html.contains("Version 2.0.3")); + assert!(html.contains("2.0.3")); }; p.cargo("doc") diff --git a/src/tools/cargo/tests/testsuite/features2.rs b/src/tools/cargo/tests/testsuite/features2.rs index 68fecb863..9238de2c6 100644 --- a/src/tools/cargo/tests/testsuite/features2.rs +++ b/src/tools/cargo/tests/testsuite/features2.rs @@ -1431,9 +1431,10 @@ fn edition_2021_workspace_member() { p.cargo("check") .with_stderr( "\ -warning: some crates are on edition 2021 which defaults to `resolver = \"2\"`, but virtual workspaces default to `resolver = \"1\"` +warning: virtual workspace defaulting to `resolver = \"1\"` despite one or more workspace members being on edition 2021 which implies `resolver = \"2\"` note: to keep the current resolver, specify `workspace.resolver = \"1\"` in the workspace root's manifest note: to use the edition 2021 resolver, specify `workspace.resolver = \"2\"` in the workspace root's manifest +note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions [CHECKING] a v0.1.0 [..] [FINISHED] [..] ", diff --git a/src/tools/cargo/tests/testsuite/freshness.rs b/src/tools/cargo/tests/testsuite/freshness.rs index f28f1ff46..d450cbbd9 100644 --- a/src/tools/cargo/tests/testsuite/freshness.rs +++ b/src/tools/cargo/tests/testsuite/freshness.rs @@ -2786,7 +2786,7 @@ fn verify_source_before_recompile() { "vendor/bar/src/lib.rs", r#"compile_error!("You shall not pass!");"#, ); - // Should ignore modifed sources without any recompile. + // Should ignore modified sources without any recompile. p.cargo("check --verbose") .with_stderr( "\ @@ -2799,7 +2799,7 @@ fn verify_source_before_recompile() { // Add a `RUSTFLAGS` to trigger a recompile. // - // Cargo should refuse to build because of checksum verfication failure. + // Cargo should refuse to build because of checksum verification failure. // Cargo shouldn't recompile dependency `bar`. p.cargo("check --verbose") .env("RUSTFLAGS", "-W warnings") diff --git a/src/tools/cargo/tests/testsuite/future_incompat_report.rs b/src/tools/cargo/tests/testsuite/future_incompat_report.rs index 4d2c66d17..c52bf25a9 100644 --- a/src/tools/cargo/tests/testsuite/future_incompat_report.rs +++ b/src/tools/cargo/tests/testsuite/future_incompat_report.rs @@ -369,7 +369,7 @@ fn suggestions_for_updates() { // project or something). This could use some more consideration of how to // handle this better (maybe only trigger an update if it hasn't updated // in a long while?). - p.cargo("update -p without_updates").run(); + p.cargo("update without_updates").run(); let update_message = "\ - Some affected dependencies have newer versions available. diff --git a/src/tools/cargo/tests/testsuite/git.rs b/src/tools/cargo/tests/testsuite/git.rs index f60ee978a..e27315346 100644 --- a/src/tools/cargo/tests/testsuite/git.rs +++ b/src/tools/cargo/tests/testsuite/git.rs @@ -742,11 +742,11 @@ fn update_with_shared_deps() { // By default, not transitive updates println!("dep1 update"); - p.cargo("update -p dep1").with_stdout("").run(); + p.cargo("update dep1").with_stdout("").run(); // Don't do anything bad on a weird --precise argument println!("bar bad precise update"); - p.cargo("update -p bar --precise 0.1.2") + p.cargo("update bar --precise 0.1.2") .with_status(101) .with_stderr( "\ @@ -764,14 +764,14 @@ Caused by: // Specifying a precise rev to the old rev shouldn't actually update // anything because we already have the rev in the db. println!("bar precise update"); - p.cargo("update -p bar --precise") + p.cargo("update bar --precise") .arg(&old_head.to_string()) .with_stdout("") .run(); - // Updating aggressively should, however, update the repo. - println!("dep1 aggressive update"); - p.cargo("update -p dep1 --aggressive") + // Updating recursively should, however, update the repo. + println!("dep1 recursive update"); + p.cargo("update dep1 --recursive") .with_stderr(&format!( "[UPDATING] git repository `{}`\n\ [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ @@ -795,7 +795,7 @@ Caused by: .run(); // We should be able to update transitive deps - p.cargo("update -p bar") + p.cargo("update bar") .with_stderr(&format!( "[UPDATING] git repository `{}`", git_project.url() @@ -1183,7 +1183,7 @@ fn two_deps_only_update_one() { let oid = git::commit(&repo); println!("dep1 head sha: {}", oid_to_short_sha(oid)); - p.cargo("update -p dep1") + p.cargo("update dep1") .with_stderr(&format!( "[UPDATING] git repository `{}`\n\ [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ @@ -1881,14 +1881,14 @@ fn update_ambiguous() { .build(); p.cargo("generate-lockfile").run(); - p.cargo("update -p bar") + p.cargo("update bar") .with_status(101) .with_stderr( "\ [ERROR] There are multiple `bar` packages in your project, and the specification `bar` \ is ambiguous. -Please re-run this command with `-p ` where `` is one of the \ -following: +Please re-run this command with one of the \ +following specifications: bar@0.[..].0 bar@0.[..].0 ", @@ -1928,7 +1928,7 @@ fn update_one_dep_in_repo_with_many_deps() { .build(); p.cargo("generate-lockfile").run(); - p.cargo("update -p bar") + p.cargo("update bar") .with_stderr(&format!("[UPDATING] git repository `{}`", bar.url())) .run(); } @@ -2091,7 +2091,7 @@ fn update_one_source_updates_all_packages_in_that_git_source() { git::add(&repo); git::commit(&repo); - p.cargo("update -p dep").run(); + p.cargo("update dep").run(); let lockfile = p.read_lockfile(); assert!( !lockfile.contains(&rev1.to_string()), @@ -2577,9 +2577,6 @@ Caused by: Caused by: failed to parse manifest at `[..]` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 8, column 21 | diff --git a/src/tools/cargo/tests/testsuite/inheritable_workspace_fields.rs b/src/tools/cargo/tests/testsuite/inheritable_workspace_fields.rs index cc261a47f..47437102a 100644 --- a/src/tools/cargo/tests/testsuite/inheritable_workspace_fields.rs +++ b/src/tools/cargo/tests/testsuite/inheritable_workspace_fields.rs @@ -1234,8 +1234,11 @@ fn error_workspace_false() { [ERROR] failed to parse manifest at `[CWD]/Cargo.toml` Caused by: + TOML parse error at line 7, column 41 + | + 7 | description = { workspace = false } + | ^^^^^ `workspace` cannot be false - in `package.description.workspace` ", ) .run(); @@ -1321,9 +1324,6 @@ fn error_malformed_workspace_root() { "\ [ERROR] failed to parse manifest at `[..]/foo/Cargo.toml` -Caused by: - [..] - Caused by: [..] | diff --git a/src/tools/cargo/tests/testsuite/install.rs b/src/tools/cargo/tests/testsuite/install.rs index 0c7fc5037..0a3670e6c 100644 --- a/src/tools/cargo/tests/testsuite/install.rs +++ b/src/tools/cargo/tests/testsuite/install.rs @@ -71,6 +71,18 @@ fn toolchain() { .run(); } +#[cargo_test] +fn url() { + pkg("foo", "0.0.1"); + cargo_process("install https://github.com/bar/foo") + .with_status(101) + .with_stderr( + "\ +[ERROR] invalid package name: `https://github.com/bar/foo` + Use `cargo install --git https://github.com/bar/foo` if you meant to install from a git repository.") + .run(); +} + #[cargo_test] fn simple_with_message_format() { pkg("foo", "0.0.1"); @@ -1600,8 +1612,13 @@ fn inline_version_without_name() { pkg("foo", "0.1.2"); cargo_process("install @0.1.1") - .with_status(101) - .with_stderr("error: missing crate name for `@0.1.1`") + .with_status(1) + .with_stderr( + "error: invalid value '@0.1.1' for '[crate]...': missing crate name before '@' + +For more information, try '--help'. +", + ) .run(); } @@ -1612,7 +1629,7 @@ fn inline_and_explicit_version() { cargo_process("install foo@0.1.1 --version 0.1.1") .with_status(101) - .with_stderr("error: cannot specify both `@0.1.1` and `--version`") + .with_stderr("error: cannot specify both `@` and `--version `") .run(); } @@ -1827,7 +1844,7 @@ fn install_empty_argument() { cargo_process("install") .arg("") .with_status(1) - .with_stderr_contains("[ERROR] a value is required for '[crate]...' but none was supplied") + .with_stderr_contains("[ERROR] invalid value '' for '[crate]...': crate name is empty") .run(); } @@ -2275,9 +2292,9 @@ fn failed_install_retains_temp_directory() { .unwrap(); // Find the path in the output. - let start = stderr.find("found at `").unwrap() + 10; - let end = stderr[start..].find('.').unwrap() - 1; - let path = Path::new(&stderr[start..(end + start)]); + let stderr = stderr.split_once("found at `").unwrap().1; + let end = stderr.find('.').unwrap() - 1; + let path = Path::new(&stderr[..end]); assert!(path.exists()); assert!(path.join("release/deps").exists()); } @@ -2426,3 +2443,23 @@ fn ambiguous_registry_vs_local_package() { .run(); assert_has_installed_exe(cargo_home(), "foo"); } + +#[cargo_test] +fn install_with_redundant_default_mode() { + pkg("foo", "0.0.1"); + + cargo_process("install foo --release") + .with_stderr( + "\ +error: unexpected argument '--release' found + + tip: `--release` is the default for `cargo install`; instead `--debug` is supported + +Usage: cargo[EXE] install [OPTIONS] [crate]... + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/install_upgrade.rs b/src/tools/cargo/tests/testsuite/install_upgrade.rs index ae641ba98..580117f5c 100644 --- a/src/tools/cargo/tests/testsuite/install_upgrade.rs +++ b/src/tools/cargo/tests/testsuite/install_upgrade.rs @@ -230,12 +230,14 @@ fn ambiguous_version_no_longer_allowed() { cargo_process("install foo --version=1.0") .with_stderr( "\ -[ERROR] the `--version` provided, `1.0`, is not a valid semver version: cannot parse '1.0' as a semver +[ERROR] invalid value '1.0' for '--version ': cannot parse '1.0' as a SemVer version -if you want to specify semver range, add an explicit qualifier, like ^1.0 + tip: if you want to specify SemVer range, add an explicit qualifier, like '^1.0' + +For more information, try '--help'. ", ) - .with_status(101) + .with_status(1) .run(); } diff --git a/src/tools/cargo/tests/testsuite/lints.rs b/src/tools/cargo/tests/testsuite/lints.rs index 854de69e9..21139d00a 100644 --- a/src/tools/cargo/tests/testsuite/lints.rs +++ b/src/tools/cargo/tests/testsuite/lints.rs @@ -3,72 +3,6 @@ use cargo_test_support::project; use cargo_test_support::registry::Package; -#[cargo_test] -fn package_requires_option() { - let foo = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [lints.rust] - unsafe_code = "forbid" - "#, - ) - .file("src/lib.rs", "") - .build(); - - foo.cargo("check") - .with_stderr( - "\ -warning: unused manifest key `lints` (may be supported in a future version) - -this Cargo does not support nightly features, but if you -switch to nightly channel you can pass -`-Zlints` to enable this feature. -[CHECKING] [..] -[FINISHED] [..] -", - ) - .run(); -} - -#[cargo_test] -fn workspace_requires_option() { - let foo = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [workspace.lints.rust] - unsafe_code = "forbid" - "#, - ) - .file("src/lib.rs", "") - .build(); - - foo.cargo("check") - .with_stderr( - "\ -warning: [CWD]/Cargo.toml: unused manifest key `lints` (may be supported in a future version) - -this Cargo does not support nightly features, but if you -switch to nightly channel you can pass -`-Zlints` to enable this feature. -[CHECKING] [..] -[FINISHED] [..] -", - ) - .run(); -} - #[cargo_test] fn dependency_warning_ignored() { let foo = project() @@ -133,53 +67,55 @@ fn malformed_on_stable() { .build(); foo.cargo("check") + .with_status(101) .with_stderr( "\ -warning: unused manifest key `lints` (may be supported in a future version) +error: failed to parse manifest[..] -this Cargo does not support nightly features, but if you -switch to nightly channel you can pass -`-Zlints` to enable this feature. -[CHECKING] [..] -[FINISHED] [..] +Caused by: + TOML parse error at line 2, column 25 + | + 2 | lints = 20 + | ^^ + invalid type: integer `20`, expected a lints table ", ) .run(); } #[cargo_test] -fn malformed_on_nightly() { +fn fail_on_invalid_tool() { let foo = project() .file( "Cargo.toml", r#" - lints = 20 [package] name = "foo" version = "0.0.1" authors = [] + [workspace.lints.super-awesome-linter] + unsafe_code = "forbid" "#, ) .file("src/lib.rs", "") .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr( "\ -error: failed to parse manifest[..] +[..] Caused by: - invalid type: integer `20`, expected a map + unsupported `super-awesome-linter` in `[lints]`, must be one of rust, clippy, rustdoc ", ) .run(); } #[cargo_test] -fn fail_on_invalid_tool() { +fn invalid_type_in_lint_value() { let foo = project() .file( "Cargo.toml", @@ -187,24 +123,26 @@ fn fail_on_invalid_tool() { [package] name = "foo" version = "0.0.1" - authors = [] - [workspace.lints.super-awesome-linter] - unsafe_code = "forbid" + [workspace.lints.rust] + rust-2018-idioms = -1 "#, ) .file("src/lib.rs", "") .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr( "\ -[..] +error: failed to parse manifest at `[..]/Cargo.toml` Caused by: - unsupported `super-awesome-linter` in `[lints]`, must be one of rust, clippy, rustdoc + TOML parse error at line 7, column 36 + | + 7 | rust-2018-idioms = -1 + | ^^ + invalid type: integer `-1`, expected a string or map ", ) .run(); @@ -228,8 +166,7 @@ fn fail_on_tool_injection() { .file("src/lib.rs", "") .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr( "\ @@ -260,8 +197,7 @@ fn fail_on_redundant_tool() { .file("src/lib.rs", "") .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr( "\ @@ -292,8 +228,7 @@ fn fail_on_conflicting_tool() { .file("src/lib.rs", "") .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr( "\ @@ -331,8 +266,7 @@ pub fn foo(num: i32) -> u32 { ) .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr_contains( "\ @@ -370,8 +304,7 @@ pub fn foo(num: i32) -> u32 { ) .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr_contains( "\ @@ -381,6 +314,49 @@ error: usage of an `unsafe` block .run(); } +#[cargo_test] +fn workspace_and_package_lints() { + let foo = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [lints] + workspace = true + [lints.rust] + "unsafe_code" = "allow" + + [workspace.lints.rust] + "unsafe_code" = "deny" + "#, + ) + .file( + "src/lib.rs", + " +pub fn foo(num: i32) -> u32 { + unsafe { std::mem::transmute(num) } +} +", + ) + .build(); + + foo.cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] failed to parse manifest at `[CWD]/Cargo.toml` + +Caused by: + cannot override `workspace.lints` in `lints`, either remove the overrides or `lints.workspace = true` and manually specify the lints +", + ) + .run(); +} + #[cargo_test] fn attribute_has_precedence() { let foo = project() @@ -408,9 +384,8 @@ pub fn foo(num: i32) -> u32 { ) .build(); - foo.cargo("check -Zlints") + foo.cargo("check") .arg("-v") // Show order of rustflags on failure - .masquerade_as_nightly_cargo(&["lints"]) .run(); } @@ -439,10 +414,9 @@ pub fn foo(num: i32) -> u32 { ) .build(); - foo.cargo("check -Zlints") + foo.cargo("check") .arg("-v") // Show order of rustflags on failure .env("RUSTFLAGS", "-Aunsafe_code") - .masquerade_as_nightly_cargo(&["lints"]) .run(); } @@ -475,9 +449,9 @@ pub fn foo(num: i32) -> u32 { ) .build(); - foo.cargo("check -Zlints") + foo.cargo("check") .arg("-v") // Show order of rustflags on failure - .masquerade_as_nightly_cargo(&["lints", "profile-rustflags"]) + .masquerade_as_nightly_cargo(&["profile-rustflags"]) .run(); } @@ -512,9 +486,8 @@ pub fn foo(num: i32) -> u32 { ) .build(); - foo.cargo("check -Zlints") + foo.cargo("check") .arg("-v") // Show order of rustflags on failure - .masquerade_as_nightly_cargo(&["lints"]) .run(); } @@ -552,8 +525,7 @@ pub fn foo() -> u32 { ) .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_status(101) .with_stderr_contains( "\ @@ -597,9 +569,7 @@ pub fn foo() -> u32 { ) .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) - .run(); + foo.cargo("check").run(); } #[cargo_test] @@ -627,8 +597,7 @@ pub fn foo() -> u32 { ) .build(); - foo.cargo("doc -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("doc") .with_status(101) .with_stderr_contains( "\ @@ -671,8 +640,7 @@ pub const Ĕ: i32 = 2; ) .build(); - foo.cargo("check -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("check") .with_stderr( "\ [CHECKING] foo v0.0.1 ([CWD]) @@ -681,8 +649,7 @@ pub const Ĕ: i32 = 2; ) .run(); - foo.cargo("test --doc -Zlints") - .masquerade_as_nightly_cargo(&["lints"]) + foo.cargo("test --doc") .with_stderr( "\ [COMPILING] foo v0.0.1 ([CWD]) diff --git a/src/tools/cargo/tests/testsuite/list_availables.rs b/src/tools/cargo/tests/testsuite/list_availables.rs index 6bbbeb160..fe635a19b 100644 --- a/src/tools/cargo/tests/testsuite/list_availables.rs +++ b/src/tools/cargo/tests/testsuite/list_availables.rs @@ -8,6 +8,7 @@ const BIN: u8 = 1 << 1; const TEST: u8 = 1 << 2; const BENCH: u8 = 1 << 3; const PACKAGE: u8 = 1 << 4; +const TARGET: u8 = 1 << 5; fn list_availables_test(command: &str, targets: u8) { let full_project = project() @@ -154,6 +155,20 @@ No benches available. error: \"--test\" takes one argument. No tests available. +", + ) + .with_status(101) + .run(); + } + + if targets & TARGET != 0 { + empty_project + .cargo(&format!("{} --target", command)) + .with_stderr( + "\ +error: \"--target\" takes a target architecture as an argument. + +Run `[..]` to see possible targets. ", ) .with_status(101) @@ -163,52 +178,52 @@ No tests available. #[cargo_test] fn build_list_availables() { - list_availables_test("build", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("build", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] fn check_list_availables() { - list_availables_test("check", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("check", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] fn doc_list_availables() { - list_availables_test("doc", BIN | PACKAGE); + list_availables_test("doc", BIN | PACKAGE | TARGET); } #[cargo_test] fn fix_list_availables() { - list_availables_test("fix", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("fix", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] fn run_list_availables() { - list_availables_test("run", EXAMPLE | BIN | PACKAGE); + list_availables_test("run", EXAMPLE | BIN | PACKAGE | TARGET); } #[cargo_test] fn test_list_availables() { - list_availables_test("test", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("test", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] fn bench_list_availables() { - list_availables_test("bench", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("bench", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] fn install_list_availables() { - list_availables_test("install", EXAMPLE | BIN); + list_availables_test("install", EXAMPLE | BIN | TARGET); } #[cargo_test] fn rustdoc_list_availables() { - list_availables_test("rustdoc", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("rustdoc", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] fn rustc_list_availables() { - list_availables_test("rustc", EXAMPLE | BIN | TEST | BENCH | PACKAGE); + list_availables_test("rustc", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET); } #[cargo_test] @@ -218,12 +233,12 @@ fn pkgid_list_availables() { #[cargo_test] fn tree_list_availables() { - list_availables_test("tree", PACKAGE); + list_availables_test("tree", PACKAGE | TARGET); } #[cargo_test] fn clean_list_availables() { - list_availables_test("clean", PACKAGE); + list_availables_test("clean", PACKAGE | TARGET); } #[cargo_test] diff --git a/src/tools/cargo/tests/testsuite/login.rs b/src/tools/cargo/tests/testsuite/login.rs index 16bd29dce..0eec734ce 100644 --- a/src/tools/cargo/tests/testsuite/login.rs +++ b/src/tools/cargo/tests/testsuite/login.rs @@ -197,8 +197,8 @@ fn bad_asymmetric_token_args() { .build(); // These cases are kept brief as the implementation is covered by clap, so this is only smoke testing that we have clap configured correctly. - cargo_process("login -Zcredential-process -- --key-subject") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -Zasymmetric-token -- --key-subject") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(registry.index_url()) .with_stderr_contains( " error: a value is required for '--key-subject ' but none was supplied", @@ -228,8 +228,8 @@ fn login_with_asymmetric_token_and_subject_on_stdin() { .no_configure_token() .build(); let credentials = credentials_toml(); - cargo_process("login -v -Z credential-process -- --key-subject=foo") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -v -Z asymmetric-token -- --key-subject=foo") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(registry.index_url()) .with_stderr_contains( "\ @@ -286,8 +286,8 @@ fn login_with_asymmetric_token_on_stdin() { .no_configure_token() .build(); let credentials = credentials_toml(); - cargo_process("login -vZ credential-process --registry alternative") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -v -Z asymmetric-token --registry alternative") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .with_stderr( "\ [UPDATING] [..] @@ -308,8 +308,8 @@ fn login_with_generate_asymmetric_token() { .no_configure_token() .build(); let credentials = credentials_toml(); - cargo_process("login -Z credential-process --registry alternative") - .masquerade_as_nightly_cargo(&["credential-process"]) + cargo_process("login -Z asymmetric-token --registry alternative") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .with_stderr("[UPDATING] `alternative` index\nk3.public.[..]") .run(); let credentials = fs::read_to_string(&credentials).unwrap(); diff --git a/src/tools/cargo/tests/testsuite/logout.rs b/src/tools/cargo/tests/testsuite/logout.rs index 7b5e10de2..6829cec2a 100644 --- a/src/tools/cargo/tests/testsuite/logout.rs +++ b/src/tools/cargo/tests/testsuite/logout.rs @@ -83,8 +83,7 @@ fn default_registry_configured() { check_token(Some("dummy-token"), Some("dummy-registry")); check_token(Some("crates-io-token"), None); - cargo_process("logout -Zunstable-options") - .masquerade_as_nightly_cargo(&["cargo-logout"]) + cargo_process("logout") .with_stderr( "\ [LOGOUT] token for `dummy-registry` has been removed from local storage @@ -97,8 +96,24 @@ fn default_registry_configured() { check_token(None, Some("dummy-registry")); check_token(Some("crates-io-token"), None); - cargo_process("logout -Zunstable-options") - .masquerade_as_nightly_cargo(&["cargo-logout"]) + cargo_process("logout") .with_stderr("[LOGOUT] not currently logged in to `dummy-registry`") .run(); } + +#[cargo_test] +fn logout_asymmetric() { + let _registry = registry::RegistryBuilder::new() + .token(cargo_test_support::registry::Token::rfc_key()) + .build(); + + cargo_process("logout --registry crates-io -Zasymmetric-token") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) + .with_stderr("[LOGOUT] secret-key for `crates-io` has been removed from local storage") + .run(); + + cargo_process("logout --registry crates-io -Zasymmetric-token") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) + .with_stderr("[LOGOUT] not currently logged in to `crates-io`") + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/lto.rs b/src/tools/cargo/tests/testsuite/lto.rs index 40b4f7ca2..b4972a64d 100644 --- a/src/tools/cargo/tests/testsuite/lto.rs +++ b/src/tools/cargo/tests/testsuite/lto.rs @@ -453,10 +453,8 @@ fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto) krate, krate_info, line, line2, stderr ); } - let actual_lto = if let Some(index) = line.find("-C lto=") { - let s = &line[index..]; - let end = s.find(' ').unwrap(); - let mode = &line[index..index + end]; + let actual_lto = if let Some((_, line)) = line.split_once("-C lto=") { + let mode = line.splitn(2, ' ').next().unwrap(); if mode == "off" { Lto::Off } else { diff --git a/src/tools/cargo/tests/testsuite/metadata.rs b/src/tools/cargo/tests/testsuite/metadata.rs index ac2cec396..fbead4dea 100644 --- a/src/tools/cargo/tests/testsuite/metadata.rs +++ b/src/tools/cargo/tests/testsuite/metadata.rs @@ -1821,8 +1821,11 @@ fn cargo_metadata_with_invalid_authors_field() { r#"[ERROR] failed to parse manifest at `[..]` Caused by: - invalid type: string "", expected a vector of strings or workspace - in `package.authors`"#, + TOML parse error at line 3, column 27 + | + 3 | authors = "" + | ^^ + invalid type: string "", expected a vector of strings or workspace"#, ) .run(); } @@ -1846,8 +1849,11 @@ fn cargo_metadata_with_invalid_version_field() { r#"[ERROR] failed to parse manifest at `[..]` Caused by: - invalid type: integer `1`, expected SemVer version - in `package.version`"#, + TOML parse error at line 3, column 27 + | + 3 | version = 1 + | ^ + invalid type: integer `1`, expected SemVer version"#, ) .run(); } @@ -1871,8 +1877,11 @@ fn cargo_metadata_with_invalid_publish_field() { r#"[ERROR] failed to parse manifest at `[..]` Caused by: - invalid type: string "foo", expected a boolean, a vector of strings, or workspace - in `package.publish`"#, + TOML parse error at line 3, column 27 + | + 3 | publish = "foo" + | ^^^^^ + invalid type: string "foo", expected a boolean, a vector of strings, or workspace"#, ) .run(); } diff --git a/src/tools/cargo/tests/testsuite/new.rs b/src/tools/cargo/tests/testsuite/new.rs index b9ddcf2d7..91a2871e9 100644 --- a/src/tools/cargo/tests/testsuite/new.rs +++ b/src/tools/cargo/tests/testsuite/new.rs @@ -95,7 +95,7 @@ fn simple_git() { let fp = paths::root().join("foo/.gitignore"); let contents = fs::read_to_string(&fp).unwrap(); - assert_eq!(contents, "/target\n/Cargo.lock\n",); + assert_eq!(contents, "/target\n",); cargo_process("build").cwd(&paths::root().join("foo")).run(); } @@ -112,7 +112,7 @@ fn simple_hg() { let fp = paths::root().join("foo/.hgignore"); let contents = fs::read_to_string(&fp).unwrap(); - assert_eq!(contents, "^target$\n^Cargo.lock$\n",); + assert_eq!(contents, "^target$\n",); cargo_process("build").cwd(&paths::root().join("foo")).run(); } diff --git a/src/tools/cargo/tests/testsuite/offline.rs b/src/tools/cargo/tests/testsuite/offline.rs index 5f164dbeb..e68425319 100644 --- a/src/tools/cargo/tests/testsuite/offline.rs +++ b/src/tools/cargo/tests/testsuite/offline.rs @@ -673,7 +673,7 @@ fn main(){ .with_stdout("1.2.9") .run(); // updates happen without updating the index - p2.cargo("update -p present_dep --precise 1.2.3 --offline") + p2.cargo("update present_dep --precise 1.2.3 --offline") .with_status(0) .with_stderr( "\ @@ -706,7 +706,7 @@ fn main(){ .run(); // No v1.2.8 loaded into the cache so expect failure. - p2.cargo("update -p present_dep --precise 1.2.8 --offline") + p2.cargo("update present_dep --precise 1.2.8 --offline") .with_status(101) .with_stderr( "\ diff --git a/src/tools/cargo/tests/testsuite/owner.rs b/src/tools/cargo/tests/testsuite/owner.rs index 7b38bcc5e..fc0e0b5c4 100644 --- a/src/tools/cargo/tests/testsuite/owner.rs +++ b/src/tools/cargo/tests/testsuite/owner.rs @@ -117,8 +117,8 @@ fn simple_add_with_asymmetric() { // The http_api server will check that the authorization is correct. // If the authorization was not sent then we would get an unauthorized error. p.cargo("owner -a username") - .arg("-Zcredential-process") - .masquerade_as_nightly_cargo(&["credential-process"]) + .arg("-Zasymmetric-token") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(registry.index_url()) .with_status(0) .run(); @@ -184,9 +184,9 @@ fn simple_remove_with_asymmetric() { // The http_api server will check that the authorization is correct. // If the authorization was not sent then we would get an unauthorized error. p.cargo("owner -r username") - .arg("-Zcredential-process") + .arg("-Zasymmetric-token") .replace_crates_io(registry.index_url()) - .masquerade_as_nightly_cargo(&["credential-process"]) + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .with_status(0) .run(); } diff --git a/src/tools/cargo/tests/testsuite/patch.rs b/src/tools/cargo/tests/testsuite/patch.rs index f2f077d7d..a467f60b5 100644 --- a/src/tools/cargo/tests/testsuite/patch.rs +++ b/src/tools/cargo/tests/testsuite/patch.rs @@ -1965,8 +1965,8 @@ fn update_unused_new_version() { // Restore the lock file, and see if `update` will work, too. fs::copy(p.root().join("Cargo.lock.bak"), p.root().join("Cargo.lock")).unwrap(); - // Try `update -p`. - p.cargo("update -p bar") + // Try `update `. + p.cargo("update bar") .with_stderr( "\ [UPDATING] `dummy-registry` index @@ -2425,7 +2425,7 @@ fn can_update_with_alt_reg() { p.cargo("check").with_stderr("[FINISHED] [..]").run(); // This does nothing, due to `=` requirement. - p.cargo("update -p bar") + p.cargo("update bar") .with_stderr( "\ [UPDATING] `alternative` index @@ -2658,3 +2658,45 @@ failed to select a version for `qux` which could resolve this conflict"#, ) .run(); } + +#[cargo_test] +fn mismatched_version_with_prerelease() { + Package::new("prerelease-deps", "0.0.1").publish(); + // A patch to a location that has an prerelease version + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + prerelease-deps = "0.1.0" + + [patch.crates-io] + prerelease-deps = { path = "./prerelease-deps" } + "#, + ) + .file("src/lib.rs", "") + .file( + "prerelease-deps/Cargo.toml", + &basic_manifest("prerelease-deps", "0.1.1-pre1"), + ) + .file("prerelease-deps/src/lib.rs", "") + .build(); + + p.cargo("generate-lockfile") + .with_status(101) + .with_stderr( + r#"[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for the requirement `prerelease-deps = "^0.1.0"` +candidate versions found which didn't match: 0.1.1-pre1, 0.0.1 +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `foo v0.1.0 [..]` +if you are looking for the prerelease package it needs to be specified explicitly + prerelease-deps = { version = "0.1.1-pre1" } +perhaps a crate was updated and forgotten to be re-vendored?"#, + ) + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/pkgid.rs b/src/tools/cargo/tests/testsuite/pkgid.rs index 3e3e4692a..88d991e80 100644 --- a/src/tools/cargo/tests/testsuite/pkgid.rs +++ b/src/tools/cargo/tests/testsuite/pkgid.rs @@ -4,22 +4,31 @@ use cargo_test_support::project; use cargo_test_support::registry::Package; #[cargo_test] -fn simple() { - Package::new("bar", "0.1.0").publish(); +fn local() { let p = project() .file( "Cargo.toml", r#" + [workspace] + members = ["bar"] + [package] name = "foo" version = "0.1.0" edition = "2018" - - [dependencies] - bar = "0.1.0" "#, ) .file("src/main.rs", "fn main() {}") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + edition = "2018" + "#, + ) + .file("bar/src/main.rs", "fn main() {}") .build(); p.cargo("generate-lockfile").run(); @@ -28,16 +37,38 @@ fn simple() { .with_stdout(format!("file://[..]{}#0.1.0", p.root().to_str().unwrap())) .run(); - p.cargo("pkgid bar") - .with_stdout("https://github.com/rust-lang/crates.io-index#bar@0.1.0") + // Bad file URL. + p.cargo("pkgid ./Cargo.toml") + .with_status(101) + .with_stderr( + "\ +error: invalid package ID specification: `./Cargo.toml` + +Caused by: + package ID specification `./Cargo.toml` looks like a file path, maybe try file://[..]/Cargo.toml +", + ) + .run(); + + // Bad file URL with similar name. + p.cargo("pkgid './bar'") + .with_status(101) + .with_stderr( + "\ +error: invalid package ID specification: `./bar` + +Did you mean `bar`? + +Caused by: + package ID specification `./bar` looks like a file path, maybe try file://[..]/bar +", + ) .run(); } #[cargo_test] -fn suggestion_bad_pkgid() { +fn registry() { Package::new("crates-io", "0.1.0").publish(); - Package::new("two-ver", "0.1.0").publish(); - Package::new("two-ver", "0.2.0").publish(); let p = project() .file( "Cargo.toml", @@ -49,16 +80,18 @@ fn suggestion_bad_pkgid() { [dependencies] crates-io = "0.1.0" - two-ver = "0.1.0" - two-ver2 = { package = "two-ver", version = "0.2.0" } "#, ) - .file("src/lib.rs", "") + .file("src/main.rs", "fn main() {}") .file("cratesio", "") .build(); p.cargo("generate-lockfile").run(); + p.cargo("pkgid crates-io") + .with_stdout("https://github.com/rust-lang/crates.io-index#crates-io@0.1.0") + .run(); + // Bad URL. p.cargo("pkgid https://example.com/crates-io") .with_status(101) @@ -83,45 +116,81 @@ error: package ID specification `crates_io` did not match any packages ", ) .run(); +} - // Bad version. - p.cargo("pkgid two-ver:0.3.0") +#[cargo_test] +fn multiple_versions() { + Package::new("two-ver", "0.1.0").publish(); + Package::new("two-ver", "0.2.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2018" + + [dependencies] + two-ver = "0.1.0" + two-ver2 = { package = "two-ver", version = "0.2.0" } + "#, + ) + .file("src/lib.rs", "") + .file("cratesio", "") + .build(); + + p.cargo("generate-lockfile").run(); + + p.cargo("pkgid two-ver:0.2.0") + .with_stdout("https://github.com/rust-lang/crates.io-index#two-ver@0.2.0") + .run(); + + // Incomplete version. + p.cargo("pkgid two-ver@0") .with_status(101) .with_stderr( "\ -error: package ID specification `two-ver@0.3.0` did not match any packages -Did you mean one of these? - +error: There are multiple `two-ver` packages in your project, and the specification `two-ver@0` is ambiguous. +Please re-run this command with one of the following specifications: two-ver@0.1.0 two-ver@0.2.0 ", ) .run(); - // Bad file URL. - p.cargo("pkgid ./Cargo.toml") + // Incomplete version. + p.cargo("pkgid two-ver@0.2") + .with_stdout( + "\ +https://github.com/rust-lang/crates.io-index#two-ver@0.2.0 +", + ) + .run(); + + // Ambiguous. + p.cargo("pkgid two-ver") .with_status(101) .with_stderr( "\ -error: invalid package ID specification: `./Cargo.toml` - -Caused by: - package ID specification `./Cargo.toml` looks like a file path, maybe try file://[..]/Cargo.toml +error: There are multiple `two-ver` packages in your project, and the specification `two-ver` is ambiguous. +Please re-run this command with one of the following specifications: + two-ver@0.1.0 + two-ver@0.2.0 ", ) .run(); - // Bad file URL with similar name. - p.cargo("pkgid './cratesio'") + // Bad version. + p.cargo("pkgid two-ver:0.3.0") .with_status(101) .with_stderr( "\ -error: invalid package ID specification: `./cratesio` - -Did you mean `crates-io`? +error: package ID specification `two-ver@0.3.0` did not match any packages +Did you mean one of these? -Caused by: - package ID specification `./cratesio` looks like a file path, maybe try file://[..]/cratesio + two-ver@0.1.0 + two-ver@0.2.0 ", ) .run(); diff --git a/src/tools/cargo/tests/testsuite/profile_config.rs b/src/tools/cargo/tests/testsuite/profile_config.rs index 26104e7e7..143c050f9 100644 --- a/src/tools/cargo/tests/testsuite/profile_config.rs +++ b/src/tools/cargo/tests/testsuite/profile_config.rs @@ -370,7 +370,7 @@ fn profile_config_mixed_types() { #[cargo_test] fn named_config_profile() { - // Exercises config named profies. + // Exercises config named profiles. // foo -> middle -> bar -> dev // middle exists in Cargo.toml, the others in .cargo/config use super::config::ConfigBuilder; @@ -427,7 +427,7 @@ fn named_config_profile() { let ws = Workspace::new(&paths::root().join("Cargo.toml"), &config).unwrap(); let profiles = Profiles::new(&ws, profile_name).unwrap(); - let crates_io = cargo::core::source::SourceId::crates_io(&config).unwrap(); + let crates_io = cargo::core::SourceId::crates_io(&config).unwrap(); let a_pkg = PackageId::new("a", "0.1.0", crates_io).unwrap(); let dep_pkg = PackageId::new("dep", "0.1.0", crates_io).unwrap(); diff --git a/src/tools/cargo/tests/testsuite/profile_custom.rs b/src/tools/cargo/tests/testsuite/profile_custom.rs index ea6b54c95..f7139e552 100644 --- a/src/tools/cargo/tests/testsuite/profile_custom.rs +++ b/src/tools/cargo/tests/testsuite/profile_custom.rs @@ -543,7 +543,9 @@ fn clean_custom_dirname() { assert!(!p.build_dir().join("release").is_dir()); // This should clean 'other' - p.cargo("clean --profile=other").with_stderr("").run(); + p.cargo("clean --profile=other") + .with_stderr("[REMOVED] [..] files, [..] total") + .run(); assert!(p.build_dir().join("debug").is_dir()); assert!(!p.build_dir().join("other").is_dir()); } diff --git a/src/tools/cargo/tests/testsuite/profile_overrides.rs b/src/tools/cargo/tests/testsuite/profile_overrides.rs index dc9bafba1..65d9f3b51 100644 --- a/src/tools/cargo/tests/testsuite/profile_overrides.rs +++ b/src/tools/cargo/tests/testsuite/profile_overrides.rs @@ -267,6 +267,60 @@ found package specs: bar, bar@0.5.0", .run(); } +#[cargo_test] +fn profile_override_spec_with_version() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + bar = { path = "bar" } + + [profile.dev.package."bar:0.5.0"] + codegen-units = 2 + "#, + ) + .file("src/lib.rs", "") + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("check -v") + .with_stderr_contains("[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]") + .run(); +} + +#[cargo_test] +fn profile_override_spec_with_partial_version() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + bar = { path = "bar" } + + [profile.dev.package."bar:0.5"] + codegen-units = 2 + "#, + ) + .file("src/lib.rs", "") + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) + .file("bar/src/lib.rs", "") + .build(); + + p.cargo("check -v") + .with_stderr_contains("[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]") + .run(); +} + #[cargo_test] fn profile_override_spec() { let p = project() diff --git a/src/tools/cargo/tests/testsuite/profiles.rs b/src/tools/cargo/tests/testsuite/profiles.rs index 465ab3b99..531c02700 100644 --- a/src/tools/cargo/tests/testsuite/profiles.rs +++ b/src/tools/cargo/tests/testsuite/profiles.rs @@ -744,7 +744,7 @@ Caused by: .run(); } -#[cargo_test(nightly, reason = "debug options stabilized in 1.70")] +#[cargo_test] fn debug_options_valid() { let build = |option| { let p = project() diff --git a/src/tools/cargo/tests/testsuite/publish.rs b/src/tools/cargo/tests/testsuite/publish.rs index 50ad697d5..67569bf3b 100644 --- a/src/tools/cargo/tests/testsuite/publish.rs +++ b/src/tools/cargo/tests/testsuite/publish.rs @@ -194,8 +194,8 @@ fn simple_publish_with_asymmetric() { .file("src/main.rs", "fn main() {}") .build(); - p.cargo("publish --no-verify -Zcredential-process --registry dummy-registry") - .masquerade_as_nightly_cargo(&["credential-process"]) + p.cargo("publish --no-verify -Zasymmetric-token --registry dummy-registry") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .with_stderr( "\ [UPDATING] `dummy-registry` index @@ -921,6 +921,48 @@ You may press ctrl-c [..] ); } +#[cargo_test] +fn publish_failed_with_index_and_only_allowed_registry() { + let registry = RegistryBuilder::new() + .http_api() + .http_index() + .alternative() + .build(); + + let p = project().build(); + + let _ = repo(&paths::root().join("foo")) + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + license = "MIT" + description = "foo" + documentation = "foo" + homepage = "foo" + repository = "foo" + publish = ["alternative"] + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("publish") + .arg("--index") + .arg(registry.index_url().as_str()) + .with_status(101) + .with_stderr( + "\ +[NOTE] Found `alternative` as only allowed registry. Publishing to it automatically. +[ERROR] command-line argument --index requires --token to be specified +", + ) + .run(); +} + #[cargo_test] fn publish_fail_with_no_registry_specified() { let p = project().build(); @@ -1923,6 +1965,7 @@ Caused by: headers: HTTP/1.1 400 Content-Length: 7 + Connection: close body: go away diff --git a/src/tools/cargo/tests/testsuite/registry.rs b/src/tools/cargo/tests/testsuite/registry.rs index 8982b1cb6..f485180c9 100644 --- a/src/tools/cargo/tests/testsuite/registry.rs +++ b/src/tools/cargo/tests/testsuite/registry.rs @@ -807,7 +807,7 @@ required by package `foo v0.0.1 ([..])` ) .run(); - p.cargo("update -p baz") + p.cargo("update baz") .with_stderr_contains( "\ [UPDATING] `[..]` index @@ -952,7 +952,7 @@ fn update_lockfile() { Package::new("bar", "0.0.3").publish(); paths::home().join(".cargo/registry").rm_rf(); println!("0.0.2 update"); - p.cargo("update -p bar --precise 0.0.2") + p.cargo("update bar --precise 0.0.2") .with_stderr( "\ [UPDATING] `[..]` index @@ -975,7 +975,7 @@ fn update_lockfile() { .run(); println!("0.0.3 update"); - p.cargo("update -p bar") + p.cargo("update bar") .with_stderr( "\ [UPDATING] `[..]` index @@ -1000,7 +1000,7 @@ fn update_lockfile() { println!("new dependencies update"); Package::new("bar", "0.0.4").dep("spam", "0.2.5").publish(); Package::new("spam", "0.2.5").publish(); - p.cargo("update -p bar") + p.cargo("update bar") .with_stderr( "\ [UPDATING] `[..]` index @@ -1012,7 +1012,7 @@ fn update_lockfile() { println!("new dependencies update"); Package::new("bar", "0.0.5").publish(); - p.cargo("update -p bar") + p.cargo("update bar") .with_stderr( "\ [UPDATING] `[..]` index @@ -1433,7 +1433,7 @@ fn update_transitive_dependency() { Package::new("b", "0.1.1").publish(); - p.cargo("update -pb") + p.cargo("update b") .with_stderr( "\ [UPDATING] `[..]` index @@ -1504,7 +1504,7 @@ fn update_backtracking_ok() { .dep("cookie", "0.1.0") .publish(); - p.cargo("update -p hyper") + p.cargo("update hyper") .with_stderr( "\ [UPDATING] `[..]` index @@ -1555,7 +1555,7 @@ fn update_multiple_packages() { Package::new("b", "0.1.1").publish(); Package::new("c", "0.1.1").publish(); - p.cargo("update -pa -pb") + p.cargo("update a b") .with_stderr( "\ [UPDATING] `[..]` index @@ -1565,7 +1565,7 @@ fn update_multiple_packages() { ) .run(); - p.cargo("update -pb -pc") + p.cargo("update b c") .with_stderr( "\ [UPDATING] `[..]` index @@ -1671,7 +1671,7 @@ fn update_same_prefix_oh_my_how_was_this_a_bug() { .publish(); p.cargo("generate-lockfile").run(); - p.cargo("update -pfoobar --precise=0.2.0").run(); + p.cargo("update foobar --precise=0.2.0").run(); } #[cargo_test] @@ -1756,12 +1756,12 @@ fn use_semver_package_incorrectly() { .with_status(101) .with_stderr( "\ -error: no matching package found -searched package name: `a` -prerelease package needs to be specified explicitly -a = { version = \"0.1.1-alpha.0\" } +error: failed to select a version for the requirement `a = \"^0.1\"` +candidate versions found which didn't match: 0.1.1-alpha.0 location searched: [..] required by package `b v0.1.0 ([..])` +if you are looking for the prerelease package it needs to be specified explicitly + a = { version = \"0.1.1-alpha.0\" } ", ) .run(); @@ -2604,7 +2604,9 @@ fn ignores_unknown_index_version_git() { fn ignores_unknown_index_version() { // If the version field is not understood, it is ignored. Package::new("bar", "1.0.0").publish(); - Package::new("bar", "1.0.1").schema_version(9999).publish(); + Package::new("bar", "1.0.1") + .schema_version(u32::MAX) + .publish(); let p = project() .file( @@ -2630,6 +2632,41 @@ fn ignores_unknown_index_version() { .run(); } +#[cargo_test] +fn unknown_index_version_error() { + // If the version field is not understood, it is ignored. + Package::new("bar", "1.0.1") + .schema_version(u32::MAX) + .publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = "1.0" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("generate-lockfile") + .with_status(101) + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[ERROR] no matching package named `bar` found +location searched: registry `crates-io` +required by package `foo v0.1.0 ([CWD])` +", + ) + .run(); +} + #[cargo_test] fn protocol() { cargo_process("install bar") diff --git a/src/tools/cargo/tests/testsuite/registry_auth.rs b/src/tools/cargo/tests/testsuite/registry_auth.rs index 4422c638a..df2bdf565 100644 --- a/src/tools/cargo/tests/testsuite/registry_auth.rs +++ b/src/tools/cargo/tests/testsuite/registry_auth.rs @@ -6,9 +6,12 @@ use cargo_test_support::{project, Execs, Project}; fn cargo(p: &Project, s: &str) -> Execs { let mut e = p.cargo(s); - e.masquerade_as_nightly_cargo(&["registry-auth", "credential-process"]) - .arg("-Zregistry-auth") - .arg("-Zcredential-process"); + e.masquerade_as_nightly_cargo(&["asymmetric-token"]) + .arg("-Zasymmetric-token"); + e.env( + "CARGO_REGISTRY_GLOBAL_CREDENTIAL_PROVIDERS", + "cargo:paseto cargo:token", + ); e } @@ -43,7 +46,7 @@ static SUCCESS_OUTPUT: &'static str = "\ "; #[cargo_test] -fn requires_nightly() { +fn requires_credential_provider() { let _registry = RegistryBuilder::new() .alternative() .auth_required() @@ -55,14 +58,14 @@ fn requires_nightly() { .with_status(101) .with_stderr( r#"[UPDATING] `alternative` index -[DOWNLOADING] crates ... -error: failed to download from `[..]/dl/bar/0.0.1/download` +error: failed to download `bar v0.0.1 (registry `alternative`)` Caused by: - failed to get successful HTTP response from `[..]` (127.0.0.1), got 401 - body: - Unauthorized message from server. -"#, + unable to get packages from source + +Caused by: + authenticated registries require a credential-provider to be configured + see https://doc.rust-lang.org/cargo/reference/registry-authentication.html for details"#, ) .run(); } diff --git a/src/tools/cargo/tests/testsuite/replace.rs b/src/tools/cargo/tests/testsuite/replace.rs index c11c49330..b9de51d2f 100644 --- a/src/tools/cargo/tests/testsuite/replace.rs +++ b/src/tools/cargo/tests/testsuite/replace.rs @@ -533,7 +533,7 @@ fn override_adds_some_deps() { p.cargo("check").with_stdout("").run(); Package::new("baz", "0.1.2").publish(); - p.cargo("update -p") + p.cargo("update") .arg(&format!("{}#bar", foo.url())) .with_stderr( "\ @@ -542,7 +542,7 @@ fn override_adds_some_deps() { ", ) .run(); - p.cargo("update -p https://github.com/rust-lang/crates.io-index#bar") + p.cargo("update https://github.com/rust-lang/crates.io-index#bar") .with_stderr( "\ [UPDATING] `dummy-registry` index @@ -1298,3 +1298,157 @@ fn override_plus_dep() { .with_stderr_contains("error: cyclic package dependency: [..]") .run(); } + +#[cargo_test] +fn override_generic_matching_other_versions() { + Package::new("bar", "0.1.0+a").publish(); + + let bar = git::repo(&paths::root().join("override")) + .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) + .file("src/lib.rs", "pub fn bar() {}") + .build(); + + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + bar = "0.1.0" + + [replace] + "bar:0.1.0" = {{ git = '{}' }} + "#, + bar.url() + ), + ) + .file( + "src/lib.rs", + "extern crate bar; pub fn foo() { bar::bar(); }", + ) + .build(); + + p.cargo("check") + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[UPDATING] git repository `[..]` +[ERROR] failed to get `bar` as a dependency of package `foo v0.0.1 ([..]/foo)` + +Caused by: + replacement specification `https://github.com/rust-lang/crates.io-index#bar@0.1.0` matched 0.1.0+a and tried to override it with 0.1.0 + avoid matching unrelated packages by being more specific +", + ) + .with_status(101) + .run(); +} + +#[cargo_test] +fn override_respects_spec_metadata() { + Package::new("bar", "0.1.0+a").publish(); + + let bar = git::repo(&paths::root().join("override")) + .file("Cargo.toml", &basic_manifest("bar", "0.1.0+a")) + .file("src/lib.rs", "pub fn bar() {}") + .build(); + + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + bar = "0.1.0" + + [replace] + "bar:0.1.0+notTheBuild" = {{ git = '{}' }} + "#, + bar.url() + ), + ) + .file( + "src/lib.rs", + "extern crate bar; pub fn foo() { bar::bar(); }", + ) + .build(); + + p.cargo("check") + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[WARNING] package replacement is not used: https://github.com/rust-lang/crates.io-index#bar@0.1.0+notTheBuild +[DOWNLOADING] crates ... +[DOWNLOADED] bar v0.1.0+a (registry `dummy-registry`) +[CHECKING] bar v0.1.0+a +[CHECKING] foo v0.0.1 ([..]/foo) +[..] +[..] +[..] +[..] +[..] +[..] +[..] +error: could not compile `foo` (lib) due to previous error +", + ) + .with_status(101) + .run(); +} + +#[cargo_test] +fn override_spec_metadata_is_optional() { + Package::new("bar", "0.1.0+a").publish(); + + let bar = git::repo(&paths::root().join("override")) + .file("Cargo.toml", &basic_manifest("bar", "0.1.0+a")) + .file("src/lib.rs", "pub fn bar() {}") + .build(); + + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + bar = "0.1.0" + + [replace] + "bar:0.1.0" = {{ git = '{}' }} + "#, + bar.url() + ), + ) + .file( + "src/lib.rs", + "extern crate bar; pub fn foo() { bar::bar(); }", + ) + .build(); + + p.cargo("check") + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[UPDATING] git repository `[..]` +[CHECKING] bar v0.1.0+a (file://[..]) +[CHECKING] foo v0.0.1 ([CWD]) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/run.rs b/src/tools/cargo/tests/testsuite/run.rs index 64cf4e16c..c58c239ac 100644 --- a/src/tools/cargo/tests/testsuite/run.rs +++ b/src/tools/cargo/tests/testsuite/run.rs @@ -37,6 +37,43 @@ fn quiet_arg() { .run(); } +#[cargo_test] +fn unsupported_silent_arg() { + let p = project() + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) + .build(); + + p.cargo("run -s") + .with_stderr( + "\ +error: unexpected argument '--silent' found + + tip: a similar argument exists: '--quiet' + +Usage: cargo[EXE] run [OPTIONS] [args]... + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); + + p.cargo("run --silent") + .with_stderr( + "\ +error: unexpected argument '--silent' found + + tip: a similar argument exists: '--quiet' + +Usage: cargo[EXE] run [OPTIONS] [args]... + +For more information, try '--help'. +", + ) + .with_status(1) + .run(); +} + #[cargo_test] fn quiet_arg_and_verbose_arg() { let p = project() diff --git a/src/tools/cargo/tests/testsuite/rust_version.rs b/src/tools/cargo/tests/testsuite/rust_version.rs index 91711cf1a..21321b7c5 100644 --- a/src/tools/cargo/tests/testsuite/rust_version.rs +++ b/src/tools/cargo/tests/testsuite/rust_version.rs @@ -44,8 +44,48 @@ fn rust_version_bad_caret() { .cargo("check") .with_status(101) .with_stderr( - "error: failed to parse manifest at `[..]`\n\n\ - Caused by:\n `rust-version` must be a value like \"1.32\"", + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"^1.43\" + | ^^^^^^^ + unexpected version requirement, expected a version like \"1.32\"", + ) + .run(); +} + +#[cargo_test] +fn rust_version_good_pre_release() { + project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + rust-version = "1.43.0-beta.1" + [[bin]] + name = "foo" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build() + .cargo("check") + .with_status(101) + .with_stderr( + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"1.43.0-beta.1\" + | ^^^^^^^^^^^^^^^ + unexpected prerelease field, expected a version like \"1.32\"", ) .run(); } @@ -70,8 +110,15 @@ fn rust_version_bad_pre_release() { .cargo("check") .with_status(101) .with_stderr( - "error: failed to parse manifest at `[..]`\n\n\ - Caused by:\n `rust-version` must be a value like \"1.32\"", + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"1.43-beta.1\" + | ^^^^^^^^^^^^^ + unexpected prerelease field, expected a version like \"1.32\"", ) .run(); } @@ -96,8 +143,15 @@ fn rust_version_bad_nonsense() { .cargo("check") .with_status(101) .with_stderr( - "error: failed to parse manifest at `[..]`\n\n\ - Caused by:\n `rust-version` must be a value like \"1.32\"", + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"foodaddle\" + | ^^^^^^^^^^^ + expected a version like \"1.32\"", ) .run(); } @@ -131,7 +185,7 @@ fn rust_version_too_high() { } #[cargo_test] -fn rust_version_dependency_fails() { +fn dependency_rust_version_newer_than_rustc() { Package::new("bar", "0.0.1") .rust_version("1.2345.0") .file("src/lib.rs", "fn other_stuff() {}") @@ -161,13 +215,196 @@ fn rust_version_dependency_fails() { error: package `bar v0.0.1` cannot be built because it requires \ rustc 1.2345.0 or newer, while the currently active rustc version is [..]\n\ Either upgrade to rustc 1.2345.0 or newer, or use\n\ - cargo update -p bar@0.0.1 --precise ver\n\ + cargo update bar@0.0.1 --precise ver\n\ where `ver` is the latest version of `bar` supporting rustc [..]", ) .run(); p.cargo("check --ignore-rust-version").run(); } +#[cargo_test] +fn dependency_rust_version_newer_than_package() { + Package::new("bar", "1.6.0") + .rust_version("1.65.0") + .file("src/lib.rs", "fn other_stuff() {}") + .publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + rust-version = "1.60.0" + [dependencies] + bar = "1.0.0" + "#, + ) + .file("src/main.rs", "fn main(){}") + .build(); + + p.cargo("check --ignore-rust-version") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + // This shouldn't fail + .with_status(101) + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for the requirement `bar = \"^1.0.0\"` +candidate versions found which didn't match: 1.6.0 +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `foo v0.0.1 ([CWD])` +perhaps a crate was updated and forgotten to be re-vendored? +", + ) + .run(); + p.cargo("check") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + .with_status(101) + // This should have a better error message + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for the requirement `bar = \"^1.0.0\"` +candidate versions found which didn't match: 1.6.0 +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `foo v0.0.1 ([CWD])` +perhaps a crate was updated and forgotten to be re-vendored? +", + ) + .run(); +} + +#[cargo_test] +fn dependency_rust_version_older_and_newer_than_package() { + Package::new("bar", "1.5.0") + .rust_version("1.55.0") + .file("src/lib.rs", "fn other_stuff() {}") + .publish(); + Package::new("bar", "1.6.0") + .rust_version("1.65.0") + .file("src/lib.rs", "fn other_stuff() {}") + .publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + rust-version = "1.60.0" + [dependencies] + bar = "1.0.0" + "#, + ) + .file("src/main.rs", "fn main(){}") + .build(); + + p.cargo("check --ignore-rust-version") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + // This should pick 1.6.0 + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.5.0 (registry `dummy-registry`) +[CHECKING] bar v1.5.0 +[CHECKING] [..] +[FINISHED] [..] +", + ) + .run(); + p.cargo("check") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + .with_stderr( + "\ +[FINISHED] [..] +", + ) + .run(); +} + +#[cargo_test] +fn workspace_with_mixed_rust_version() { + Package::new("bar", "1.4.0") + .rust_version("1.45.0") + .file("src/lib.rs", "fn other_stuff() {}") + .publish(); + Package::new("bar", "1.5.0") + .rust_version("1.55.0") + .file("src/lib.rs", "fn other_stuff() {}") + .publish(); + Package::new("bar", "1.6.0") + .rust_version("1.65.0") + .file("src/lib.rs", "fn other_stuff() {}") + .publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["lower"] + + [package] + name = "higher" + version = "0.0.1" + authors = [] + rust-version = "1.60.0" + [dependencies] + bar = "1.0.0" + "#, + ) + .file("src/main.rs", "fn main() {}") + .file( + "lower/Cargo.toml", + r#" + [package] + name = "lower" + version = "0.0.1" + authors = [] + rust-version = "1.50.0" + [dependencies] + bar = "1.0.0" + "#, + ) + .file("lower/src/main.rs", "fn main() {}") + .build(); + + p.cargo("check --ignore-rust-version") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + // This should pick 1.6.0 + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.4.0 (registry `dummy-registry`) +[CHECKING] bar v1.4.0 +[CHECKING] [..] +[FINISHED] [..] +", + ) + .run(); + p.cargo("check") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + .with_stderr( + "\ +[FINISHED] [..] +", + ) + .run(); +} + #[cargo_test] fn rust_version_older_than_edition() { project() diff --git a/src/tools/cargo/tests/testsuite/rustdocflags.rs b/src/tools/cargo/tests/testsuite/rustdocflags.rs index 6992961ce..c37d5a826 100644 --- a/src/tools/cargo/tests/testsuite/rustdocflags.rs +++ b/src/tools/cargo/tests/testsuite/rustdocflags.rs @@ -110,17 +110,19 @@ fn whitespace() { .with_status(101) .run(); - const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d"; p.cargo("doc") .env_remove("__CARGO_TEST_FORCE_ARGFILE") // Not applicable for argfile. .env( "RUSTDOCFLAGS", - format!("--crate-version {}", SPACED_VERSION), + "--crate-version 1111\n2222\t3333\u{00a0}4444", ) .run(); let contents = p.read_file("target/doc/foo/index.html"); - assert!(contents.contains(SPACED_VERSION)); + assert!(contents.contains("1111")); + assert!(contents.contains("2222")); + assert!(contents.contains("3333")); + assert!(contents.contains("4444")); } #[cargo_test] diff --git a/src/tools/cargo/tests/testsuite/script.rs b/src/tools/cargo/tests/testsuite/script.rs index 0c0441d62..96f3a5eb4 100644 --- a/src/tools/cargo/tests/testsuite/script.rs +++ b/src/tools/cargo/tests/testsuite/script.rs @@ -162,7 +162,7 @@ fn warn_when_plugin_masks_manifest_on_stable() { .with_stdout("") .with_stderr( "\ -warning: external subcommand `echo.rs` has the appearance of a manfiest-command +warning: external subcommand `echo.rs` has the appearance of a manifest-command This was previously accepted but will be phased out when `-Zscript` is stabilized. For more information, see issue #12207 . ", @@ -208,11 +208,10 @@ error: running `echo.rs` requires `-Zscript` #[cargo_test] fn clean_output_with_edition() { let script = r#"#!/usr/bin/env cargo - -//! ```cargo -//! [package] -//! edition = "2018" -//! ``` +```cargo +[package] +edition = "2018" +``` fn main() { println!("Hello world!"); @@ -240,10 +239,9 @@ fn main() { #[cargo_test] fn warning_without_edition() { let script = r#"#!/usr/bin/env cargo - -//! ```cargo -//! [package] -//! ``` +```cargo +[package] +``` fn main() { println!("Hello world!"); @@ -625,11 +623,10 @@ fn missing_script_rs() { fn test_name_same_as_dependency() { Package::new("script", "1.0.0").publish(); let script = r#"#!/usr/bin/env cargo - -//! ```cargo -//! [dependencies] -//! script = "1.0.0" -//! ``` +```cargo +[dependencies] +script = "1.0.0" +``` fn main() { println!("Hello world!"); @@ -662,11 +659,10 @@ fn main() { #[cargo_test] fn test_path_dep() { let script = r#"#!/usr/bin/env cargo - -//! ```cargo -//! [dependencies] -//! bar.path = "./bar" -//! ``` +```cargo +[dependencies] +bar.path = "./bar" +``` fn main() { println!("Hello world!"); @@ -980,6 +976,7 @@ fn cmd_clean_with_embedded() { .with_stderr( "\ [WARNING] `package.edition` is unspecified, defaulting to `2021` +[REMOVED] [..] files, [..] total ", ) .run(); diff --git a/src/tools/cargo/tests/testsuite/search.rs b/src/tools/cargo/tests/testsuite/search.rs index 1f6f40327..4c3155c8f 100644 --- a/src/tools/cargo/tests/testsuite/search.rs +++ b/src/tools/cargo/tests/testsuite/search.rs @@ -89,7 +89,8 @@ fn setup() -> RegistryBuilder { fn not_update() { let registry = setup().build(); - use cargo::core::{Shell, Source, SourceId}; + use cargo::core::{Shell, SourceId}; + use cargo::sources::source::Source; use cargo::sources::RegistrySource; use cargo::util::Config; @@ -172,8 +173,7 @@ fn colored_results() { fn auth_required_failure() { let server = setup().auth_required().no_configure_token().build(); - cargo_process("-Zregistry-auth search postgres") - .masquerade_as_nightly_cargo(&["registry-auth"]) + cargo_process("search postgres") .replace_crates_io(server.index_url()) .with_status(101) .with_stderr_contains("[ERROR] no token found, please run `cargo login`") @@ -184,8 +184,7 @@ fn auth_required_failure() { fn auth_required() { let server = setup().auth_required().build(); - cargo_process("-Zregistry-auth search postgres") - .masquerade_as_nightly_cargo(&["registry-auth"]) + cargo_process("search postgres") .replace_crates_io(server.index_url()) .with_stdout_contains(SEARCH_RESULTS) .run(); diff --git a/src/tools/cargo/tests/testsuite/source_replacement.rs b/src/tools/cargo/tests/testsuite/source_replacement.rs index 24f2ca3e3..41f3fe0b7 100644 --- a/src/tools/cargo/tests/testsuite/source_replacement.rs +++ b/src/tools/cargo/tests/testsuite/source_replacement.rs @@ -243,7 +243,52 @@ fn undefined_default() { .replace_crates_io(crates_io.index_url()) .with_status(101) .with_stderr( - "[ERROR] no index found for registry: `undefined` + "[ERROR] registry index was not found in any configuration: `undefined` +", + ) + .run(); +} + +#[cargo_test] +fn source_replacement_with_registry_url() { + let alternative = RegistryBuilder::new().alternative().http_api().build(); + Package::new("bar", "0.0.1").alternative(true).publish(); + + let crates_io = setup_replacement(&format!( + r#" + [source.crates-io] + replace-with = 'using-registry-url' + + [source.using-registry-url] + registry = '{}' + "#, + alternative.index_url() + )); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + [dependencies.bar] + version = "0.0.1" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check") + .replace_crates_io(crates_io.index_url()) + .with_stderr( + "\ +[UPDATING] `using-registry-url` index +[DOWNLOADING] crates ... +[DOWNLOADED] bar v0.0.1 (registry `using-registry-url`) +[CHECKING] bar v0.0.1 +[CHECKING] foo v0.0.1 ([CWD]) +[FINISHED] dev [..] ", ) .run(); diff --git a/src/tools/cargo/tests/testsuite/ssh.rs b/src/tools/cargo/tests/testsuite/ssh.rs index d1701d32d..f8c12819b 100644 --- a/src/tools/cargo/tests/testsuite/ssh.rs +++ b/src/tools/cargo/tests/testsuite/ssh.rs @@ -184,10 +184,9 @@ fn known_host_works() { // Validate the fingerprint while we're here. let fingerprint = stderr .lines() - .find(|line| line.starts_with(" The ECDSA key fingerprint")) + .find_map(|line| line.strip_prefix(" The ECDSA key fingerprint is: ")) .unwrap() .trim(); - let fingerprint = &fingerprint[30..]; let finger_out = sshd.exec(&["ssh-keygen", "-l", "-f", "/etc/ssh/ssh_host_ecdsa_key.pub"]); let gen_finger = std::str::from_utf8(&finger_out.stdout).unwrap(); // diff --git a/src/tools/cargo/tests/testsuite/test.rs b/src/tools/cargo/tests/testsuite/test.rs index c6ae4ce61..5f6528109 100644 --- a/src/tools/cargo/tests/testsuite/test.rs +++ b/src/tools/cargo/tests/testsuite/test.rs @@ -4844,24 +4844,6 @@ error: 2 targets failed: .run(); } -#[cargo_test] -fn cargo_test_no_keep_going() { - let p = project() - .file("Cargo.toml", &basic_bin_manifest("foo")) - .file("src/main.rs", "") - .build(); - - p.cargo("test --keep-going") - .with_stderr( - "\ -error: unexpected argument `--keep-going` found - - tip: to run as many tests as possible without failing fast, use `--no-fail-fast`", - ) - .with_status(101) - .run(); -} - #[cargo_test] fn cargo_test_print_env_verbose() { let p = project() diff --git a/src/tools/cargo/tests/testsuite/tool_paths.rs b/src/tools/cargo/tests/testsuite/tool_paths.rs index a211b5328..5428f9d01 100644 --- a/src/tools/cargo/tests/testsuite/tool_paths.rs +++ b/src/tools/cargo/tests/testsuite/tool_paths.rs @@ -32,6 +32,93 @@ fn pathless_tools() { .run(); } +// can set a custom linker via `target.'cfg(..)'.linker` +#[cargo_test] +fn custom_linker_cfg() { + let foo = project() + .file("Cargo.toml", &basic_lib_manifest("foo")) + .file("src/lib.rs", "") + .file( + ".cargo/config", + r#" + [target.'cfg(not(target_os = "none"))'] + linker = "nonexistent-linker" + "#, + ) + .build(); + + foo.cargo("build --verbose") + .with_stderr( + "\ +[COMPILING] foo v0.5.0 ([CWD]) +[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +// custom linker set via `target.$triple.linker` have precede over `target.'cfg(..)'.linker` +#[cargo_test] +fn custom_linker_cfg_precedence() { + let target = rustc_host(); + + let foo = project() + .file("Cargo.toml", &basic_lib_manifest("foo")) + .file("src/lib.rs", "") + .file( + ".cargo/config", + &format!( + r#" + [target.'cfg(not(target_os = "none"))'] + linker = "ignored-linker" + [target.{}] + linker = "nonexistent-linker" + "#, + target + ), + ) + .build(); + + foo.cargo("build --verbose") + .with_stderr( + "\ +[COMPILING] foo v0.5.0 ([CWD]) +[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]` +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); +} + +#[cargo_test] +fn custom_linker_cfg_collision() { + let foo = project() + .file("Cargo.toml", &basic_lib_manifest("foo")) + .file("src/lib.rs", "") + .file( + ".cargo/config", + r#" + [target.'cfg(not(target_arch = "avr"))'] + linker = "nonexistent-linker1" + [target.'cfg(not(target_os = "none"))'] + linker = "nonexistent-linker2" + "#, + ) + .build(); + + foo.cargo("build --verbose") + .with_status(101) + .with_stderr(&format!( + "\ +[ERROR] several matching instances of `target.'cfg(..)'.linker` in configurations +first match `cfg(not(target_arch = \"avr\"))` located in [..]/foo/.cargo/config +second match `cfg(not(target_os = \"none\"))` located in [..]/foo/.cargo/config +", + )) + .run(); +} + #[cargo_test] fn absolute_tools() { let target = rustc_host(); @@ -393,7 +480,6 @@ fn cfg_ignored_fields() { [WARNING] unused key `ar` in [target] config table `cfg(not(target_os = \"none\"))` [WARNING] unused key `foo` in [target] config table `cfg(not(target_os = \"none\"))` [WARNING] unused key `invalid` in [target] config table `cfg(not(target_os = \"none\"))` -[WARNING] unused key `linker` in [target] config table `cfg(not(target_os = \"none\"))` [CHECKING] foo v0.0.1 ([..]) [FINISHED] [..] ", diff --git a/src/tools/cargo/tests/testsuite/tree.rs b/src/tools/cargo/tests/testsuite/tree.rs index e2e74c4f9..16cc37f7e 100644 --- a/src/tools/cargo/tests/testsuite/tree.rs +++ b/src/tools/cargo/tests/testsuite/tree.rs @@ -1675,7 +1675,7 @@ fn ambiguous_name() { .with_stderr_contains( "\ error: There are multiple `dep` packages in your project, and the specification `dep` is ambiguous. -Please re-run this command with `-p ` where `` is one of the following: +Please re-run this command with one of the following specifications: dep@1.0.0 dep@2.0.0 ", diff --git a/src/tools/cargo/tests/testsuite/update.rs b/src/tools/cargo/tests/testsuite/update.rs index d42345355..fe1d86bd7 100644 --- a/src/tools/cargo/tests/testsuite/update.rs +++ b/src/tools/cargo/tests/testsuite/update.rs @@ -1,7 +1,7 @@ //! Tests for the `cargo update` command. use cargo_test_support::registry::Package; -use cargo_test_support::{basic_manifest, project}; +use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project}; #[cargo_test] fn minor_update_two_places() { @@ -105,7 +105,7 @@ fn transitive_minor_update() { // // Also note that this is probably counterintuitive and weird. We may wish // to change this one day. - p.cargo("update -p serde") + p.cargo("update serde") .with_stderr( "\ [UPDATING] `[..]` index @@ -155,7 +155,7 @@ fn conservative() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.1.1").dep("log", "0.1").publish(); - p.cargo("update -p serde") + p.cargo("update serde") .with_stderr( "\ [UPDATING] `[..]` index @@ -381,7 +381,7 @@ fn update_precise() { Package::new("serde", "0.2.0").publish(); - p.cargo("update -p serde:0.2.1 --precise 0.2.0") + p.cargo("update serde:0.2.1 --precise 0.2.0") .with_stderr( "\ [UPDATING] `[..]` index @@ -417,7 +417,7 @@ fn update_precise_do_not_force_update_deps() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.2.2").dep("log", "0.1").publish(); - p.cargo("update -p serde:0.2.1 --precise 0.2.2") + p.cargo("update serde:0.2.1 --precise 0.2.2") .with_stderr( "\ [UPDATING] `[..]` index @@ -428,7 +428,7 @@ fn update_precise_do_not_force_update_deps() { } #[cargo_test] -fn update_aggressive() { +fn update_recursive() { Package::new("log", "0.1.0").publish(); Package::new("serde", "0.2.1").dep("log", "0.1").publish(); @@ -453,7 +453,7 @@ fn update_aggressive() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.2.2").dep("log", "0.1").publish(); - p.cargo("update -p serde:0.2.1 --aggressive") + p.cargo("update serde:0.2.1 --recursive") .with_stderr( "\ [UPDATING] `[..]` index @@ -465,7 +465,7 @@ fn update_aggressive() { } #[cargo_test] -fn update_aggressive_conflicts_with_precise() { +fn update_aggressive_alias_for_recursive() { Package::new("log", "0.1.0").publish(); Package::new("serde", "0.2.1").dep("log", "0.1").publish(); @@ -490,13 +490,50 @@ fn update_aggressive_conflicts_with_precise() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.2.2").dep("log", "0.1").publish(); - p.cargo("update -p serde:0.2.1 --precise 0.2.2 --aggressive") + p.cargo("update serde:0.2.1 --aggressive") + .with_stderr( + "\ +[UPDATING] `[..]` index +[UPDATING] log v0.1.0 -> v0.1.1 +[UPDATING] serde v0.2.1 -> v0.2.2 +", + ) + .run(); +} + +#[cargo_test] +fn update_recursive_conflicts_with_precise() { + Package::new("log", "0.1.0").publish(); + Package::new("serde", "0.2.1").dep("log", "0.1").publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + + [dependencies] + serde = "0.2" + "#, + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("check").run(); + + Package::new("log", "0.1.1").publish(); + Package::new("serde", "0.2.2").dep("log", "0.1").publish(); + + p.cargo("update serde:0.2.1 --precise 0.2.2 --recursive") .with_status(1) .with_stderr( "\ -error: the argument '--precise ' cannot be used with '--aggressive' +error: the argument '--precise ' cannot be used with '--recursive' -Usage: cargo[EXE] update --package [] --precise +Usage: cargo[EXE] update --precise ]> For more information, try '--help'. ", @@ -528,7 +565,7 @@ fn update_precise_first_run() { .file("src/lib.rs", "") .build(); - p.cargo("update -p serde --precise 0.2.0") + p.cargo("update serde --precise 0.2.0") .with_stderr( "\ [UPDATING] `[..]` index @@ -682,7 +719,7 @@ fn update_precise_first_run() { ) .run(); - p.cargo("update -p serde --precise 0.2.0") + p.cargo("update serde --precise 0.2.0") .with_stderr( "\ [UPDATING] `[..]` index @@ -758,7 +795,7 @@ fn dry_run_update() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.1.1").dep("log", "0.1").publish(); - p.cargo("update -p serde --dry-run") + p.cargo("update serde --dry-run") .with_stderr( "\ [UPDATING] `[..]` index @@ -818,7 +855,7 @@ fn precise_with_build_metadata() { Package::new("bar", "0.1.1+extra-stuff.1").publish(); Package::new("bar", "0.1.2+extra-stuff.2").publish(); - p.cargo("update -p bar --precise 0.1") + p.cargo("update bar --precise 0.1") .with_status(101) .with_stderr( "\ @@ -830,7 +867,7 @@ Caused by: ) .run(); - p.cargo("update -p bar --precise 0.1.1+does-not-match") + p.cargo("update bar --precise 0.1.1+does-not-match") .with_status(101) .with_stderr( "\ @@ -842,7 +879,7 @@ required by package `foo v0.1.0 ([ROOT]/foo)` ) .run(); - p.cargo("update -p bar --precise 0.1.1") + p.cargo("update bar --precise 0.1.1") .with_stderr( "\ [UPDATING] [..] index @@ -852,7 +889,7 @@ required by package `foo v0.1.0 ([ROOT]/foo)` .run(); Package::new("bar", "0.1.3").publish(); - p.cargo("update -p bar --precise 0.1.3+foo") + p.cargo("update bar --precise 0.1.3+foo") .with_status(101) .with_stderr( "\ @@ -864,7 +901,7 @@ required by package `foo v0.1.0 ([ROOT]/foo)` ) .run(); - p.cargo("update -p bar --precise 0.1.3") + p.cargo("update bar --precise 0.1.3") .with_stderr( "\ [UPDATING] [..] index @@ -873,3 +910,185 @@ required by package `foo v0.1.0 ([ROOT]/foo)` ) .run(); } + +#[cargo_test] +fn update_only_members_order_one() { + let git_project = git::new("rustdns", |project| { + project + .file("Cargo.toml", &basic_lib_manifest("rustdns")) + .file("src/lib.rs", "pub fn bar() {}") + }); + + let workspace_toml = format!( + r#" +[workspace.package] +version = "2.29.8" +edition = "2021" +publish = false + +[workspace] +members = [ + "rootcrate", + "subcrate", +] +resolver = "2" + +[workspace.dependencies] +# Internal crates +subcrate = {{ version = "*", path = "./subcrate" }} + +# External dependencies +rustdns = {{ version = "0.5.0", default-features = false, git = "{}" }} + "#, + git_project.url() + ); + let p = project() + .file("Cargo.toml", &workspace_toml) + .file( + "rootcrate/Cargo.toml", + r#" +[package] +name = "rootcrate" +version.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +subcrate.workspace = true +"#, + ) + .file("rootcrate/src/main.rs", "fn main() {}") + .file( + "subcrate/Cargo.toml", + r#" +[package] +name = "subcrate" +version.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +rustdns.workspace = true +"#, + ) + .file("subcrate/src/lib.rs", "pub foo() {}") + .build(); + + // First time around we should compile both foo and bar + p.cargo("generate-lockfile") + .with_stderr(&format!( + "[UPDATING] git repository `{}`\n", + git_project.url(), + )) + .run(); + // Modify a file manually, shouldn't trigger a recompile + git_project.change_file("src/lib.rs", r#"pub fn bar() { println!("hello!"); }"#); + // Commit the changes and make sure we don't trigger a recompile because the + // lock file says not to change + let repo = git2::Repository::open(&git_project.root()).unwrap(); + git::add(&repo); + git::commit(&repo); + p.change_file("Cargo.toml", &workspace_toml.replace("2.29.8", "2.29.81")); + + p.cargo("update -p rootcrate") + .with_stderr(&format!( + "\ +[UPDATING] git repository `{}` +[UPDATING] rootcrate v2.29.8 ([CWD]/rootcrate) -> v2.29.81 +[UPDATING] rustdns v0.5.0 ([..]) -> [..] +[UPDATING] subcrate v2.29.8 ([CWD]/subcrate) -> v2.29.81", + git_project.url(), + )) + .run(); +} + +#[cargo_test] +fn update_only_members_order_two() { + let git_project = git::new("rustdns", |project| { + project + .file("Cargo.toml", &basic_lib_manifest("rustdns")) + .file("src/lib.rs", "pub fn bar() {}") + }); + + let workspace_toml = format!( + r#" +[workspace.package] +version = "2.29.8" +edition = "2021" +publish = false + +[workspace] +members = [ + "crate2", + "crate1", +] +resolver = "2" + +[workspace.dependencies] +# Internal crates +crate1 = {{ version = "*", path = "./crate1" }} + +# External dependencies +rustdns = {{ version = "0.5.0", default-features = false, git = "{}" }} + "#, + git_project.url() + ); + let p = project() + .file("Cargo.toml", &workspace_toml) + .file( + "crate2/Cargo.toml", + r#" +[package] +name = "crate2" +version.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +crate1.workspace = true +"#, + ) + .file("crate2/src/main.rs", "fn main() {}") + .file( + "crate1/Cargo.toml", + r#" +[package] +name = "crate1" +version.workspace = true +edition.workspace = true +publish.workspace = true + +[dependencies] +rustdns.workspace = true +"#, + ) + .file("crate1/src/lib.rs", "pub foo() {}") + .build(); + + // First time around we should compile both foo and bar + p.cargo("generate-lockfile") + .with_stderr(&format!( + "[UPDATING] git repository `{}`\n", + git_project.url(), + )) + .run(); + // Modify a file manually, shouldn't trigger a recompile + git_project.change_file("src/lib.rs", r#"pub fn bar() { println!("hello!"); }"#); + // Commit the changes and make sure we don't trigger a recompile because the + // lock file says not to change + let repo = git2::Repository::open(&git_project.root()).unwrap(); + git::add(&repo); + git::commit(&repo); + p.change_file("Cargo.toml", &workspace_toml.replace("2.29.8", "2.29.81")); + + p.cargo("update -p crate2") + .with_stderr(&format!( + "\ +[UPDATING] git repository `{}` +[UPDATING] crate1 v2.29.8 ([CWD]/crate1) -> v2.29.81 +[UPDATING] crate2 v2.29.8 ([CWD]/crate2) -> v2.29.81 +[UPDATING] rustdns v0.5.0 ([..]) -> [..]", + git_project.url(), + )) + .run(); +} diff --git a/src/tools/cargo/tests/testsuite/workspaces.rs b/src/tools/cargo/tests/testsuite/workspaces.rs index c6698f76a..4f8997b38 100644 --- a/src/tools/cargo/tests/testsuite/workspaces.rs +++ b/src/tools/cargo/tests/testsuite/workspaces.rs @@ -1090,9 +1090,6 @@ fn new_warning_with_corrupt_ws() { failed to parse manifest at `[..]foo/Cargo.toml` -Caused by: - could not parse input as TOML - Caused by: TOML parse error at line 1, column 5 | diff --git a/src/tools/cargo/tests/testsuite/yank.rs b/src/tools/cargo/tests/testsuite/yank.rs index c0bd24776..9aff2fc84 100644 --- a/src/tools/cargo/tests/testsuite/yank.rs +++ b/src/tools/cargo/tests/testsuite/yank.rs @@ -76,14 +76,14 @@ fn explicit_version_with_asymmetric() { // The http_api server will check that the authorization is correct. // If the authorization was not sent then we would get an unauthorized error. p.cargo("yank --version 0.0.1") - .arg("-Zcredential-process") - .masquerade_as_nightly_cargo(&["credential-process"]) + .arg("-Zasymmetric-token") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(registry.index_url()) .run(); p.cargo("yank --undo --version 0.0.1") - .arg("-Zcredential-process") - .masquerade_as_nightly_cargo(&["credential-process"]) + .arg("-Zasymmetric-token") + .masquerade_as_nightly_cargo(&["asymmetric-token"]) .replace_crates_io(registry.index_url()) .run(); } -- cgit v1.2.3