summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /src/tools/cargo/tests/testsuite
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite')
-rw-r--r--src/tools/cargo/tests/testsuite/bench.rs5
-rw-r--r--src/tools/cargo/tests/testsuite/build.rs24
-rw-r--r--src/tools/cargo/tests/testsuite/build_script.rs7
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_basic/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_multiple/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs20
l---------src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/in (renamed from src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/in)0
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/mod.rs (renamed from src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/mod.rs)9
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/out/Cargo.toml (renamed from src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/out/Cargo.toml)0
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stderr.log2
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stdout.log (renamed from src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stdout.log)0
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/build/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/change_rename_target/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/cyclic_features/mod.rs9
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/default_features/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/deprecated_default_features/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/deprecated_section/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_features/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_optional/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/dev/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/dev_build_conflict/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/dev_prefer_existing_version/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/dry_run/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/empty_dep_table/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features_empty/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features_multiple_occurrences/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features_preserve/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features_spaced_values/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features_unknown/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/features_unknown_no_features/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_branch/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_conflicts_namever/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_dev/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name_multiple/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_multiple_names/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_normalized_name/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_registry/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_rev/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/git_tag/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/infer_prerelease/mod.rs5
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_arg/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stderr.log12
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_git_name/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_name_external/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_path/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_path_name/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_path_self/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_target_empty/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/invalid_vers/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/list_features/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/list_features_path/mod.rs21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/list_features_path_no_default/mod.rs21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/locked_changed/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/locked_unchanged/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/lockfile_updated/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/manifest_path_package/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/mod.rs95
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_features/mod.rs21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_rename/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/namever/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/no_args/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/no_default_features/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/no_optional/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/offline_empty_cache/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/optional/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_features/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_git_with_path/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_features_noop/mod.rs2
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_noop/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_optional_noop/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_inline_features/mod.rs21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_dev_noop/mod.rs11
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_noop/mod.rs11
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_noop/mod.rs11
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_with_version/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_preserves_inline_table/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_git/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_path/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_with_rename/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep_features/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/path/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/path_dev/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name_conflicts_full_feature/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/path_normalized_name/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/Cargo.toml21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/src/lib.rs0
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/mod.rs31
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml21
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stderr.log7
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stdout.log0
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_sorted/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/preserve_unsorted/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/quiet/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/registry/mod.rs19
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/rename/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/require_weak/mod.rs10
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/rust_version_ignore/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/rust_version_incompatible/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/rust_version_latest/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/rust_version_older/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/sorted_table_with_dotted_item/mod.rs22
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/target/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/target_cfg/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/vers/mod.rs15
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/workspace_name/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/workspace_path/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_add/workspace_path_dev/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_features.rs1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/Cargo.toml6
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/src/lib.rs14
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs24
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/Cargo.toml6
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/Cargo.toml11
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/src/main.rs3
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/src/lib.rs14
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stderr.log1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stdout.log0
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_new/mod.rs1
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/build/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/dev/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/dry_run/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/gc_patch/mod.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/gc_profile/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/gc_replace/mod.rs17
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_arg/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_dep/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_package/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_section/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_target/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/mod.rs58
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/multiple_deps/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/multiple_dev/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/no_arg/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/offline/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/optional_feature/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/package/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/remove_basic/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/target/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/target_build/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/target_dev/mod.rs18
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/update_lock_file/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/workspace/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/workspace_non_virtual/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_remove/workspace_preserved/mod.rs16
-rw-r--r--src/tools/cargo/tests/testsuite/config.rs62
-rw-r--r--src/tools/cargo/tests/testsuite/config_include.rs112
-rw-r--r--src/tools/cargo/tests/testsuite/cross_compile.rs2
-rw-r--r--src/tools/cargo/tests/testsuite/custom_target.rs2
-rw-r--r--src/tools/cargo/tests/testsuite/directory.rs8
-rw-r--r--src/tools/cargo/tests/testsuite/doc.rs98
-rw-r--r--src/tools/cargo/tests/testsuite/features.rs99
-rw-r--r--src/tools/cargo/tests/testsuite/features2.rs35
-rw-r--r--src/tools/cargo/tests/testsuite/future_incompat_report.rs2
-rw-r--r--src/tools/cargo/tests/testsuite/git.rs68
-rw-r--r--src/tools/cargo/tests/testsuite/install.rs26
-rw-r--r--src/tools/cargo/tests/testsuite/lockfile_compat.rs78
-rw-r--r--src/tools/cargo/tests/testsuite/main.rs1
-rw-r--r--src/tools/cargo/tests/testsuite/profile_config.rs13
-rw-r--r--src/tools/cargo/tests/testsuite/profile_targets.rs51
-rw-r--r--src/tools/cargo/tests/testsuite/profiles.rs52
-rw-r--r--src/tools/cargo/tests/testsuite/required_features.rs7
-rw-r--r--src/tools/cargo/tests/testsuite/run.rs4
-rw-r--r--src/tools/cargo/tests/testsuite/rustc.rs22
-rw-r--r--src/tools/cargo/tests/testsuite/script.rs1184
-rw-r--r--src/tools/cargo/tests/testsuite/test.rs11
193 files changed, 3523 insertions, 662 deletions
diff --git a/src/tools/cargo/tests/testsuite/bench.rs b/src/tools/cargo/tests/testsuite/bench.rs
index 60ad2b60d..581acbe15 100644
--- a/src/tools/cargo/tests/testsuite/bench.rs
+++ b/src/tools/cargo/tests/testsuite/bench.rs
@@ -313,9 +313,8 @@ fn cargo_bench_failing_test() {
[FINISHED] bench [optimized] target(s) in [..]
[RUNNING] [..] (target/release/deps/foo-[..][EXE])",
)
- .with_stdout_contains(
- "[..]thread '[..]' panicked at 'assertion failed: `(left == right)`[..]",
- )
+ .with_stdout_contains("[..]thread '[..]' panicked at[..]")
+ .with_stdout_contains("[..]assertion failed[..]")
.with_stdout_contains("[..]left: `\"hello\"`[..]")
.with_stdout_contains("[..]right: `\"nope\"`[..]")
.with_stdout_contains("[..]src/main.rs:15[..]")
diff --git a/src/tools/cargo/tests/testsuite/build.rs b/src/tools/cargo/tests/testsuite/build.rs
index 7b555a71b..8cb064a6f 100644
--- a/src/tools/cargo/tests/testsuite/build.rs
+++ b/src/tools/cargo/tests/testsuite/build.rs
@@ -1334,13 +1334,13 @@ fn cargo_default_env_metadata_env_var() {
[COMPILING] bar v0.0.1 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type dylib \
--emit=[..]link \
- -C prefer-dynamic[..]-C debuginfo=2 \
+ -C prefer-dynamic[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
-C extra-filename=[..] \
--out-dir [..] \
@@ -1362,13 +1362,13 @@ fn cargo_default_env_metadata_env_var() {
[COMPILING] bar v0.0.1 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type dylib \
--emit=[..]link \
- -C prefer-dynamic[..]-C debuginfo=2 \
+ -C prefer-dynamic[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
-C extra-filename=[..] \
--out-dir [..] \
@@ -2053,7 +2053,7 @@ fn verbose_build() {
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
@@ -4074,7 +4074,7 @@ fn message_format_json_forward_stderr() {
},
"profile":{
"debug_assertions":false,
- "debuginfo":null,
+ "debuginfo":0,
"opt_level":"3",
"overflow_checks": false,
"test":false
@@ -5432,7 +5432,7 @@ fn targets_selected_all() {
// Unit tests.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]\
- -C debuginfo=2 --test [..]",
+ -C debuginfo=2 [..]--test [..]",
)
.run();
}
@@ -5449,7 +5449,7 @@ fn all_targets_no_lib() {
// Unit tests.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]\
- -C debuginfo=2 --test [..]",
+ -C debuginfo=2 [..]--test [..]",
)
.run();
}
@@ -5566,6 +5566,8 @@ fn good_jobs() {
p.cargo("build --jobs 1").run();
p.cargo("build --jobs -1").run();
+
+ p.cargo("build --jobs default").run();
}
#[cargo_test]
@@ -5599,8 +5601,8 @@ fn invalid_jobs() {
.run();
p.cargo("build --jobs over9000")
- .with_status(1)
- .with_stderr("error: Invalid value: could not parse `over9000` as a number")
+ .with_status(101)
+ .with_stderr("error: could not parse `over9000`. Number of parallel jobs should be `default` or a number.")
.run();
}
@@ -5920,7 +5922,7 @@ fn build_lib_only() {
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
diff --git a/src/tools/cargo/tests/testsuite/build_script.rs b/src/tools/cargo/tests/testsuite/build_script.rs
index 80a24960e..4840356c6 100644
--- a/src/tools/cargo/tests/testsuite/build_script.rs
+++ b/src/tools/cargo/tests/testsuite/build_script.rs
@@ -1755,7 +1755,7 @@ fn build_cmd_with_a_build_cmd() {
--extern a=[..]liba[..].rlib`
[RUNNING] `[..]/foo-[..]/build-script-build`
[RUNNING] `rustc --crate-name foo [..]lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L [..]target/debug/deps`
@@ -1926,7 +1926,6 @@ fn output_separate_lines_new() {
.run();
}
-#[cfg(not(windows))] // FIXME(#867)
#[cargo_test]
fn code_generation() {
let p = project()
@@ -1976,7 +1975,7 @@ fn code_generation() {
"\
[COMPILING] foo v0.5.0 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
-[RUNNING] `target/debug/foo`",
+[RUNNING] `target/debug/foo[EXE]`",
)
.with_stdout("Hello, World!")
.run();
@@ -5108,7 +5107,7 @@ fn duplicate_script_with_extra_env() {
p.cargo("test --workspace -Z doctest-xcompile --doc --target")
.arg(&target)
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
- .with_stdout_contains("test src/lib.rs - (line 2) ... ok")
+ .with_stdout_contains("test foo/src/lib.rs - (line 2) ... ok")
.run();
}
}
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/add_basic/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/add_basic/mod.rs
index 33889dffa..67cd948ae 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/add_basic/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_basic/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/add_multiple/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/add_multiple/mod.rs
index a9cc20575..ce5e9b71d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/add_multiple/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_multiple/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs
index 63605d8dc..ced39b99c 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_normalized_name_external/mod.rs
@@ -2,12 +2,28 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4")
+ .feature("clippy", &[])
+ .feature("heapsize", &[])
+ .feature("heapsize_impl", &[])
+ .feature("nightly", &[])
+ .feature("serde", &[])
+ .feature("serde_impl", &[])
+ .feature("serde_test", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("inflector", "0.11.4")
+ .feature("default", &["heavyweight", "lazy_static", "regex"])
+ .feature("heavyweight", &[])
+ .feature("lazy_static", &[])
+ .feature("regex", &[])
+ .feature("unstable", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/in b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/in
index 6c6a27fcf..6c6a27fcf 120000
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/in
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/in
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/mod.rs
index 705182f20..905b8c8a2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/mod.rs
@@ -2,25 +2,20 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
- let git_url = url::Url::from_directory_path(cwd.join("does-not-exist"))
- .unwrap()
- .to_string();
snapbox::cmd::Command::cargo_ui()
.arg("add")
- .args(["fake-git", "--git", &git_url])
+ .arg_line("+nightly")
.current_dir(cwd)
.assert()
- .code(101)
+ .failure()
.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/invalid_git_external/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/out/Cargo.toml
index 3ecdb6681..3ecdb6681 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/out/Cargo.toml
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/out/Cargo.toml
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stderr.log
new file mode 100644
index 000000000..0593685ad
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stderr.log
@@ -0,0 +1,2 @@
+error: invalid character `+` in dependency name: `+nightly`
+ Use `cargo +nightly add` if you meant to use the `nightly` toolchain.
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stdout.log b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stdout.log
index e69de29bb..e69de29bb 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stdout.log
+++ b/src/tools/cargo/tests/testsuite/cargo_add/add_toolchain/stdout.log
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/build/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/build/mod.rs
index 130ecfbb0..001dd3a8f 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/build/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/build/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-build-package1", "my-build-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs
index b0bb2e03b..285ec658a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs
@@ -2,11 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
-
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .alternative(true)
+ .publish();
+ }
+
let project =
Project::from_template("tests/testsuite/cargo_add/build_prefer_existing_version/in");
let project_root = project.root();
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/change_rename_target/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/change_rename_target/mod.rs
index 94309b3ab..d1540c8ad 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/change_rename_target/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/change_rename_target/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/cyclic_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/cyclic_features/mod.rs
index 5dffac323..8b4c6123a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/cyclic_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/cyclic_features/mod.rs
@@ -2,12 +2,17 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("test_cyclic_features", "0.1.1")
+ .feature("default", &["feature-one", "feature-two"])
+ .feature("feature-one", &["feature-two"])
+ .feature("feature-two", &["feature-one"])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/default_features/mod.rs
index 88bdd8065..9d313b9d9 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/default_features/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/deprecated_default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/deprecated_default_features/mod.rs
index 10d4e4e98..c4fdd4f3e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/deprecated_default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/deprecated_default_features/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/deprecated_section/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/deprecated_section/mod.rs
index 10d4e4e98..c4fdd4f3e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/deprecated_section/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/deprecated_section/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit/mod.rs
index 065fb4f93..2b9550ce0 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_features/mod.rs
index 11ab2b1bf..8067166dc 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_features/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_optional/mod.rs
index 7557b520d..423f1a26d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/detect_workspace_inherit_optional/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/dev/mod.rs
index 112e92285..c838f1eac 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/dev/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-dev-package1", "my-dev-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/dev_build_conflict/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/dev_build_conflict/mod.rs
index 3f57c6b76..70432b529 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/dev_build_conflict/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/dev_build_conflict/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/dev_prefer_existing_version/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/dev_prefer_existing_version/mod.rs
index 1785ac820..2d3698c14 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/dev_prefer_existing_version/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/dev_prefer_existing_version/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .alternative(true)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/dry_run/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/dry_run/mod.rs
index 209d20873..438ec7b73 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/dry_run/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/dry_run/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/empty_dep_table/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/empty_dep_table/mod.rs
index f6c507188..d612a07f7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/empty_dep_table/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/empty_dep_table/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features/mod.rs
index 5e4115390..aebae9b3b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_empty/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_empty/mod.rs
index 81dffc1ee..d58c6a292 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features_empty/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features_empty/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_multiple_occurrences/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_multiple_occurrences/mod.rs
index db47f860d..4189be7ea 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features_multiple_occurrences/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features_multiple_occurrences/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_preserve/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_preserve/mod.rs
index ed99a3111..708fb4ddf 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features_preserve/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features_preserve/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_spaced_values/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_spaced_values/mod.rs
index 2ef212e59..4ee483110 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features_spaced_values/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features_spaced_values/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_unknown/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_unknown/mod.rs
index 7fd8d9529..552319402 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features_unknown/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features_unknown/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/features_unknown_no_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/features_unknown_no_features/mod.rs
index 9f59a0353..dff50a61f 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/features_unknown_no_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/features_unknown_no_features/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git/mod.rs
index bd82b3015..507fb417d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_branch/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_branch/mod.rs
index 051564566..8235a7c3c 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_branch/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_branch/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_conflicts_namever/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_conflicts_namever/mod.rs
index f123298ae..86b268b59 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_conflicts_namever/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_conflicts_namever/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_dev/mod.rs
index 9e14a4007..96be4f46e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_dev/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name/mod.rs
index 52183adf4..4a3ded8c2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name_multiple/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name_multiple/mod.rs
index a708a8ae7..a915f3472 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name_multiple/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_inferred_name_multiple/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_multiple_names/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_multiple_names/mod.rs
index 39eb6e626..3ffe10714 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_multiple_names/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_multiple_names/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_normalized_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_normalized_name/mod.rs
index 03d861856..dbad20105 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_normalized_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_normalized_name/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_registry/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_registry/mod.rs
index 6bf6f8933..e44d71470 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_registry/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_registry/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("versioned-package", ver)
+ .alternative(true)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_rev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_rev/mod.rs
index 612607203..b8a669c7a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_rev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_rev/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/git_tag/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/git_tag/mod.rs
index b355b1706..706fc9ab7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/git_tag/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/git_tag/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/infer_prerelease/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/infer_prerelease/mod.rs
index 94533f979..f2b49376a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/infer_prerelease/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/infer_prerelease/mod.rs
@@ -2,12 +2,13 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("prerelease_only", "0.2.0-alpha.1").publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_arg/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_arg/mod.rs
index 265a571bc..a4e4d268a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_arg/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_arg/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stderr.log
deleted file mode 100644
index 18656300b..000000000
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_external/stderr.log
+++ /dev/null
@@ -1,12 +0,0 @@
- Updating git repository `[ROOTURL]/case/does-not-exist/`
-...
-error: failed to load source for dependency `fake-git`
-
-Caused by:
- Unable to update [ROOTURL]/case/does-not-exist/
-
-Caused by:
- failed to clone into: [ROOT]/home/.cargo/git/db/does-not-exist-[..]
-
-Caused by:
-...
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_name/mod.rs
index 0aff8c090..2f407105d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_git_name/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/mod.rs
index e385cfc3f..4a2d01765 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_manifest/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_name_external/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_name_external/mod.rs
index 16e041738..8cb9b5129 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_name_external/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_name_external/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_path/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_path/mod.rs
index 0d26b552d..d8e6a34a6 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_path/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_path/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_name/mod.rs
index 10d841475..aec088020 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_name/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_self/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_self/mod.rs
index a64190f44..4bb32531b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_self/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_path_self/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_target_empty/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_target_empty/mod.rs
index da93c4eb8..43b3a4a79 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_target_empty/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_target_empty/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/invalid_vers/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/invalid_vers/mod.rs
index c3b4d1f97..2ad903d1f 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/invalid_vers/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/invalid_vers/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/list_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/list_features/mod.rs
index e1e1b212f..0dbf824d0 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/list_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/list_features/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/list_features_path/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/list_features_path/mod.rs
index 22733b883..e58de1c1d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/list_features_path/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/list_features_path/mod.rs
@@ -2,12 +2,29 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/list_features_path_no_default/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/list_features_path_no_default/mod.rs
index f520b2aca..0aa20873e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/list_features_path_no_default/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/list_features_path_no_default/mod.rs
@@ -2,12 +2,29 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/locked_changed/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/locked_changed/mod.rs
index 9e3e57fe5..5de047f57 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/locked_changed/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/locked_changed/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/locked_unchanged/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/locked_unchanged/mod.rs
index aba9918f7..613d8c863 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/locked_unchanged/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/locked_unchanged/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/lockfile_updated/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/lockfile_updated/mod.rs
index 33889dffa..4e99a18ef 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/lockfile_updated/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/lockfile_updated/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package", "unrelateed-crate"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/manifest_path_package/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/manifest_path_package/mod.rs
index 008c2d33d..768cdb3a3 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/manifest_path_package/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/manifest_path_package/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/mod.rs
index cd7e94e09..be7a1546b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/mod.rs
@@ -1,6 +1,7 @@
mod add_basic;
mod add_multiple;
mod add_normalized_name_external;
+mod add_toolchain;
mod build;
mod build_prefer_existing_version;
mod change_rename_target;
@@ -36,7 +37,6 @@ mod git_rev;
mod git_tag;
mod infer_prerelease;
mod invalid_arg;
-mod invalid_git_external;
mod invalid_git_name;
mod invalid_key_inherit_dependency;
mod invalid_key_overwrite_inherit_dependency;
@@ -96,6 +96,7 @@ mod path_dev;
mod path_inferred_name;
mod path_inferred_name_conflicts_full_feature;
mod path_normalized_name;
+mod preserve_features_table;
mod preserve_sorted;
mod preserve_unsorted;
mod quiet;
@@ -114,95 +115,3 @@ mod vers;
mod workspace_name;
mod workspace_path;
mod workspace_path_dev;
-
-fn init_registry() {
- cargo_test_support::registry::init();
- add_registry_packages(false);
-}
-
-fn init_alt_registry() {
- cargo_test_support::registry::alt_init();
- add_registry_packages(true);
-}
-
-fn add_registry_packages(alt: bool) {
- for name in [
- "my-package",
- "my-package1",
- "my-package2",
- "my-dev-package1",
- "my-dev-package2",
- "my-build-package1",
- "my-build-package2",
- "toml",
- "versioned-package",
- "cargo-list-test-fixture-dependency",
- "unrelateed-crate",
- ] {
- cargo_test_support::registry::Package::new(name, "0.1.1+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.2.0+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.2.3+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.4.1+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "20.0.0+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "99999.0.0+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "99999.0.0-alpha.1+my-package")
- .alternative(alt)
- .publish();
- }
-
- cargo_test_support::registry::Package::new("prerelease_only", "0.2.0-alpha.1")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new("test_breaking", "0.2.0")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new("test_nonbreaking", "0.1.1")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new("test_cyclic_features", "0.1.1")
- .alternative(alt)
- .feature("default", &["feature-one", "feature-two"])
- .feature("feature-one", &["feature-two"])
- .feature("feature-two", &["feature-one"])
- .publish();
-
- // Normalization
- cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4")
- .alternative(alt)
- .feature("clippy", &[])
- .feature("heapsize", &[])
- .feature("heapsize_impl", &[])
- .feature("nightly", &[])
- .feature("serde", &[])
- .feature("serde_impl", &[])
- .feature("serde_test", &[])
- .publish();
- cargo_test_support::registry::Package::new("inflector", "0.11.4")
- .alternative(alt)
- .feature("default", &["heavyweight", "lazy_static", "regex"])
- .feature("heavyweight", &[])
- .feature("lazy_static", &[])
- .feature("regex", &[])
- .feature("unstable", &[])
- .publish();
-
- cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
- .alternative(alt)
- .feature("nose", &[])
- .feature("mouth", &[])
- .feature("eyes", &[])
- .feature("ears", &[])
- .publish();
-}
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_features/mod.rs
index 10f824484..3cdad0e72 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_features/mod.rs
@@ -2,12 +2,29 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package1", ver).publish();
+ }
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_rename/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_rename/mod.rs
index 293ed3eea..9a94dcffa 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_rename/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/multiple_conflicts_with_rename/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/namever/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/namever/mod.rs
index 90fda1a9f..063072c79 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/namever/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/namever/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package", "my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/no_args/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/no_args/mod.rs
index 7eca17b56..aca1e5422 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/no_args/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/no_args/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/no_default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/no_default_features/mod.rs
index e72ca3be2..8a5d41c8d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/no_default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/no_default_features/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/no_optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/no_optional/mod.rs
index fdb983b21..9145528bf 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/no_optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/no_optional/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/offline_empty_cache/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/offline_empty_cache/mod.rs
index ae7485979..055b6a8a2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/offline_empty_cache/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/offline_empty_cache/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/optional/mod.rs
index 94d1cbf34..408a46ed3 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/optional/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features/mod.rs
index 88bdd8065..9d313b9d9 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/mod.rs
index e72ca3be2..8a5d41c8d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_default_features_with_no_default_features/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_features/mod.rs
index 0b2ab18b8..da55fced2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_features/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_git_with_path/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_git_with_path/mod.rs
index ab89e3a6d..fd63cc709 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_git_with_path/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_git_with_path/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_features_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_features_noop/mod.rs
index 161783282..2b9550ce0 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_features_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_features_noop/mod.rs
@@ -6,6 +6,8 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_noop/mod.rs
index 065fb4f93..2b9550ce0 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_noop/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_optional_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_optional_noop/mod.rs
index 065fb4f93..2b9550ce0 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_optional_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inherit_optional_noop/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inline_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inline_features/mod.rs
index 356b4d788..52ad6968a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inline_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_inline_features/mod.rs
@@ -2,12 +2,29 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("unrelateed-crate", ver).publish();
+ }
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_dev_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_dev_noop/mod.rs
index b418c7809..ea37368d5 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_dev_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_dev_noop/mod.rs
@@ -2,12 +2,19 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .alternative(true)
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_noop/mod.rs
index 193c5880b..120be4429 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_name_noop/mod.rs
@@ -2,12 +2,19 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .alternative(true)
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features/mod.rs
index e72ca3be2..8a5d41c8d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/mod.rs
index 88bdd8065..9d313b9d9 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_default_features_with_default_features/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs
index fdb983b21..9145528bf 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs
index 94d1cbf34..408a46ed3 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional/mod.rs
index 94d1cbf34..408a46ed3 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs
index c34c293f9..3090a7527 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs
@@ -2,12 +2,29 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package2", ver).publish();
+ }
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_noop/mod.rs
index f04405a34..fc057d852 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_noop/mod.rs
@@ -2,12 +2,19 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .alternative(true)
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_with_version/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_with_version/mod.rs
index 32674e23d..bb93cfa15 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_with_version/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_path_with_version/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_preserves_inline_table/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_preserves_inline_table/mod.rs
index 0b2ab18b8..da55fced2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_preserves_inline_table/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_preserves_inline_table/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/mod.rs
index a006c95fd..ea49a07c1 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_no_rename/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("versioned-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename/mod.rs
index e14282bc1..af96caef5 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("versioned-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/mod.rs
index c0ca2e552..734d0b99a 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_rename_with_rename_noop/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("versioned-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_git/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_git/mod.rs
index ce7a0acb0..fcf0aa5e6 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_git/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_git/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("versioned-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_path/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_path/mod.rs
index ab89e3a6d..fd63cc709 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_path/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_version_with_path/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_with_rename/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_with_rename/mod.rs
index 05cc2d109..49a0ae0eb 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_with_rename/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_with_rename/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("versioned-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep/mod.rs
index 87ed58f7f..15cfa571c 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep_features/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep_features/mod.rs
index 87ed58f7f..15cfa571c 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep_features/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/overwrite_workspace_dep_features/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/path/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/path/mod.rs
index ab89e3a6d..fd63cc709 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/path/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/path/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/path_dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/path_dev/mod.rs
index 4ae04c70a..478e602a2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/path_dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/path_dev/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name/mod.rs
index ab89e3a6d..fd63cc709 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name_conflicts_full_feature/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name_conflicts_full_feature/mod.rs
index eadd096aa..17c328ea6 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name_conflicts_full_feature/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/path_inferred_name_conflicts_full_feature/mod.rs
@@ -2,12 +2,12 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/path_normalized_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/path_normalized_name/mod.rs
index 754f2783f..8ae8a4e7d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/path_normalized_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/path_normalized_name/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/Cargo.toml
new file mode 100644
index 000000000..d32f5eb82
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/Cargo.toml
@@ -0,0 +1,21 @@
+[package]
+name = "xxx"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+your-face = { version = "99999.0.0", optional = true }
+
+[features]
+default = [
+ "a",
+ "b",
+ "c",
+]
+a = [
+ "your-face?/nose", # but not the mouth and nose
+]
+b = []
+c = []
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/src/lib.rs
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/in/src/lib.rs
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/mod.rs
new file mode 100644
index 000000000..1998fa742
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/mod.rs
@@ -0,0 +1,31 @@
+use cargo_test_support::compare::assert_ui;
+use cargo_test_support::prelude::*;
+use cargo_test_support::Project;
+
+use cargo_test_support::curr_dir;
+
+#[cargo_test]
+fn case() {
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .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("add")
+ .arg_line("your-face --no-optional")
+ .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/preserve_features_table/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml
new file mode 100644
index 000000000..39acd1016
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/out/Cargo.toml
@@ -0,0 +1,21 @@
+[package]
+name = "xxx"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+your-face = { version = "99999.0.0" }
+
+[features]
+default = [
+ "a",
+ "b",
+ "c",
+]
+a = [
+ "your-face/nose", # but not the mouth and nose
+]
+b = []
+c = []
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stderr.log b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stderr.log
new file mode 100644
index 000000000..796b9601b
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stderr.log
@@ -0,0 +1,7 @@
+ Updating `dummy-registry` index
+ Adding your-face v99999.0.0 to dependencies.
+ Features:
+ - ears
+ - eyes
+ - mouth
+ - nose
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stdout.log b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stdout.log
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_features_table/stdout.log
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_sorted/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/preserve_sorted/mod.rs
index 4dfb06ed1..aef0d3d2f 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/preserve_sorted/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_sorted/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package", "versioned-package", "toml"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/preserve_unsorted/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/preserve_unsorted/mod.rs
index 4dfb06ed1..aef0d3d2f 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/preserve_unsorted/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/preserve_unsorted/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package", "versioned-package", "toml"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/quiet/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/quiet/mod.rs
index 357843901..1a02b0802 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/quiet/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/quiet/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/registry/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/registry/mod.rs
index d5ba9ef28..d0d937815 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/registry/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/registry/mod.rs
@@ -2,12 +2,27 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_alt_registry();
+ cargo_test_support::registry::alt_init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver)
+ .alternative(true)
+ .publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/rename/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/rename/mod.rs
index 3fefcccf3..28c92d770 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/rename/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/rename/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/require_weak/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/require_weak/mod.rs
index d99e4482a..1998fa742 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/require_weak/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/require_weak/mod.rs
@@ -2,12 +2,18 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
+ .feature("nose", &[])
+ .feature("mouth", &[])
+ .feature("eyes", &[])
+ .feature("ears", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
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 9aa11eaac..a382d95f1 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
@@ -2,13 +2,11 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
-
+ cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0")
.rust_version("1.66")
.publish();
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_incompatible/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_incompatible/mod.rs
index 6baad0e05..31fb57786 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_incompatible/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_incompatible/mod.rs
@@ -2,13 +2,11 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
-
+ cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0")
.rust_version("1.66")
.publish();
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_latest/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_latest/mod.rs
index 60e38960f..7a42c566e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_latest/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_latest/mod.rs
@@ -2,13 +2,11 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
-
+ cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0")
.rust_version("1.66")
.publish();
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_older/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_older/mod.rs
index 60e38960f..7a42c566e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/rust_version_older/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/rust_version_older/mod.rs
@@ -2,13 +2,11 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
-
+ cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0")
.rust_version("1.66")
.publish();
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/sorted_table_with_dotted_item/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/sorted_table_with_dotted_item/mod.rs
index 55e4c2281..46e8708a1 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/sorted_table_with_dotted_item/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/sorted_table_with_dotted_item/mod.rs
@@ -2,12 +2,30 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in [
+ "unrelateed-crate",
+ "versioned-package",
+ "toml",
+ "my-build-package1",
+ ] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/target/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/target/mod.rs
index e263bad36..b47874949 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/target/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/target/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/target_cfg/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/target_cfg/mod.rs
index 43efe8e8d..0478ece76 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/target_cfg/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/target_cfg/mod.rs
@@ -2,12 +2,25 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for name in ["my-package1", "my-package2"] {
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new(name, ver).publish();
+ }
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/vers/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/vers/mod.rs
index fb78739e9..ee7dab2d1 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/vers/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/vers/mod.rs
@@ -2,12 +2,23 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/workspace_name/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/workspace_name/mod.rs
index ccaf850f9..2ab0807de 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/workspace_name/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/workspace_name/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/workspace_path/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/workspace_path/mod.rs
index ab89e3a6d..fd63cc709 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/workspace_path/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/workspace_path/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_add/workspace_path_dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_add/workspace_path_dev/mod.rs
index 4ae04c70a..478e602a2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_add/workspace_path_dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_add/workspace_path_dev/mod.rs
@@ -2,12 +2,24 @@ use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
-use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture-dependency", ver)
+ .publish();
+ }
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = project_root.join("primary");
diff --git a/src/tools/cargo/tests/testsuite/cargo_features.rs b/src/tools/cargo/tests/testsuite/cargo_features.rs
index 6e5531431..ed5f53a1e 100644
--- a/src/tools/cargo/tests/testsuite/cargo_features.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_features.rs
@@ -295,6 +295,7 @@ fn allow_features_to_rustc() {
.file(
"src/lib.rs",
r#"
+ #![allow(internal_features)]
#![feature(test_2018_feature)]
"#,
)
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/Cargo.toml
new file mode 100644
index 000000000..55ee0423c
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/Cargo.toml
@@ -0,0 +1,6 @@
+[workspace]
+resolver = "2"
+members = ["crates/*"]
+
+[workspace.lints.rust]
+unsafe_code = "forbid"
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/in/src/lib.rs
new file mode 100644
index 000000000..7d12d9af8
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/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/inherit_workspace_lints/mod.rs b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs
new file mode 100644
index 000000000..0b7697d20
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/mod.rs
@@ -0,0 +1,24 @@
+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]
+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(["crates/foo", "-Zlints"])
+ .current_dir(cwd)
+ .masquerade_as_nightly_cargo(&["lints"])
+ .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/inherit_workspace_lints/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/Cargo.toml
new file mode 100644
index 000000000..55ee0423c
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/Cargo.toml
@@ -0,0 +1,6 @@
+[workspace]
+resolver = "2"
+members = ["crates/*"]
+
+[workspace.lints.rust]
+unsafe_code = "forbid"
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/Cargo.toml
new file mode 100644
index 000000000..0f3fe5d94
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "foo"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+
+[lints]
+workspace = true
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/src/main.rs b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/src/main.rs
new file mode 100644
index 000000000..e7a11a969
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/crates/foo/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/src/lib.rs b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/out/src/lib.rs
new file mode 100644
index 000000000..7d12d9af8
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/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/inherit_workspace_lints/stderr.log b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stderr.log
new file mode 100644
index 000000000..90150cdf5
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stderr.log
@@ -0,0 +1 @@
+ Created binary (application) `crates/foo` package
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stdout.log b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stdout.log
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_lints/stdout.log
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml
index b7a2e9036..cef4dd48b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table.in/Cargo.toml
@@ -1,4 +1,5 @@
[workspace]
+resolver = "2"
members = [
"crates/*",
]
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml
index b7a2e9036..cef4dd48b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table/out/Cargo.toml
@@ -1,4 +1,5 @@
[workspace]
+resolver = "2"
members = [
"crates/*",
]
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml
index b7a2e9036..cef4dd48b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_edition/out/Cargo.toml
@@ -1,4 +1,5 @@
[workspace]
+resolver = "2"
members = [
"crates/*",
]
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml
index b7a2e9036..cef4dd48b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml
+++ b/src/tools/cargo/tests/testsuite/cargo_new/inherit_workspace_package_table_with_registry/out/Cargo.toml
@@ -1,4 +1,5 @@
[workspace]
+resolver = "2"
members = [
"crates/*",
]
diff --git a/src/tools/cargo/tests/testsuite/cargo_new/mod.rs b/src/tools/cargo/tests/testsuite/cargo_new/mod.rs
index 762a70b34..e895cf883 100644
--- a/src/tools/cargo/tests/testsuite/cargo_new/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_new/mod.rs
@@ -1,3 +1,4 @@
+mod inherit_workspace_lints;
mod inherit_workspace_package_table;
mod inherit_workspace_package_table_with_edition;
mod inherit_workspace_package_table_with_registry;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs
index 59a2333d6..17bc3f949 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/build/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/build/mod.rs
index f4c9dcb94..72ce478b9 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/build/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/build/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/dev/mod.rs
index 7d61fa954..d9cbdf1a7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/dev/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/dry_run/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/dry_run/mod.rs
index dca189315..2e097135d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/dry_run/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/dry_run/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/gc_patch/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/gc_patch/mod.rs
index 2c1d592fb..ec521a5bb 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/gc_patch/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/gc_patch/mod.rs
@@ -5,11 +5,9 @@ use cargo_test_support::git;
use cargo_test_support::project;
use cargo_test_support::CargoCommand;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
let git_project1 = git::new("bar1", |project| {
project
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/gc_profile/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/gc_profile/mod.rs
index 7047c92e2..98b99bec3 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/gc_profile/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/gc_profile/mod.rs
@@ -3,11 +3,22 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.2.3+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/gc_replace/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/gc_replace/mod.rs
index 717adef3e..cbcf5bc07 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/gc_replace/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/gc_replace/mod.rs
@@ -3,11 +3,22 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.2.3+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_arg/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_arg/mod.rs
index eac3c8b46..97d5c8625 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_arg/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_arg/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_dep/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_dep/mod.rs
index c4dbeae91..fb32a075f 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_dep/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_dep/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package/mod.rs
index bff09882e..d7f84c035 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs
index 5093d5d2d..d14179e0c 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section/mod.rs
index 80d42be1d..94d475059 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs
index 7be8fd628..c20cd94d2 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target/mod.rs
index 34deb6cb8..aba040a2b 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs
index e04418fa8..f187e609c 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs
index fd8b4a233..feb08cea4 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/mod.rs
@@ -28,61 +28,3 @@ mod update_lock_file;
mod workspace;
mod workspace_non_virtual;
mod workspace_preserved;
-
-fn init_registry() {
- cargo_test_support::registry::init();
- add_registry_packages(false);
-}
-
-fn add_registry_packages(alt: bool) {
- for name in [
- "clippy",
- "dbus",
- "docopt",
- "ncurses",
- "pad",
- "regex",
- "rustc-serialize",
- "toml",
- ] {
- cargo_test_support::registry::Package::new(name, "0.1.1+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.2.0+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.2.3+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.4.1+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.6.2+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "0.9.9+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "1.0.90+my-package")
- .alternative(alt)
- .publish();
- cargo_test_support::registry::Package::new(name, "20.0.0+my-package")
- .alternative(alt)
- .publish();
- }
-
- for name in ["semver", "serde"] {
- cargo_test_support::registry::Package::new(name, "0.1.1")
- .alternative(alt)
- .feature("std", &[])
- .publish();
- cargo_test_support::registry::Package::new(name, "0.9.0")
- .alternative(alt)
- .feature("std", &[])
- .publish();
- cargo_test_support::registry::Package::new(name, "1.0.90")
- .alternative(alt)
- .feature("std", &[])
- .publish();
- }
-}
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/multiple_deps/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/multiple_deps/mod.rs
index 35922b738..d0af30a30 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/multiple_deps/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/multiple_deps/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/multiple_dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/multiple_dev/mod.rs
index 5eac7e2f8..7ec2bd0b7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/multiple_dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/multiple_dev/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/no_arg/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/no_arg/mod.rs
index d0c66f9b0..f9e0e5548 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/no_arg/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/no_arg/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/offline/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/offline/mod.rs
index d03463927..e227eb095 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/offline/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/offline/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs
index cae736b34..ce8fcf712 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/optional_feature/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/optional_feature/mod.rs
index af54226bb..9ab3c4c24 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/optional_feature/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/optional_feature/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/package/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/package/mod.rs
index 2714f3197..73d01b89d 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/package/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/package/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/remove_basic/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/remove_basic/mod.rs
index 53381e6bc..7c92026a5 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/remove_basic/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/remove_basic/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/target/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/target/mod.rs
index 1447c753d..6f6fc5c61 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/target/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/target/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/target_build/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/target_build/mod.rs
index 11afbbf8f..7adffa229 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/target_build/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/target_build/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/target_dev/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/target_dev/mod.rs
index d303c2b85..005eb7871 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/target_dev/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/target_dev/mod.rs
@@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/update_lock_file/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/update_lock_file/mod.rs
index be5bc87f5..00e7964e4 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/update_lock_file/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/update_lock_file/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.1+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/workspace/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/workspace/mod.rs
index 225fbec00..5274b07d7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/workspace/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/workspace/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/workspace_non_virtual/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/workspace_non_virtual/mod.rs
index 225fbec00..5274b07d7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/workspace_non_virtual/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/workspace_non_virtual/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/cargo_remove/workspace_preserved/mod.rs b/src/tools/cargo/tests/testsuite/cargo_remove/workspace_preserved/mod.rs
index 225fbec00..5274b07d7 100644
--- a/src/tools/cargo/tests/testsuite/cargo_remove/workspace_preserved/mod.rs
+++ b/src/tools/cargo/tests/testsuite/cargo_remove/workspace_preserved/mod.rs
@@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;
-use crate::cargo_remove::init_registry;
-
#[cargo_test]
fn case() {
- init_registry();
+ cargo_test_support::registry::init();
+ cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
+ cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
+ cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("semver", "0.1.1")
+ .feature("std", &[])
+ .publish();
+ cargo_test_support::registry::Package::new("serde", "1.0.90")
+ .feature("std", &[])
+ .publish();
+
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
diff --git a/src/tools/cargo/tests/testsuite/config.rs b/src/tools/cargo/tests/testsuite/config.rs
index b0f9d167b..5d4163818 100644
--- a/src/tools/cargo/tests/testsuite/config.rs
+++ b/src/tools/cargo/tests/testsuite/config.rs
@@ -1,7 +1,7 @@
//! Tests for config settings.
use cargo::core::{PackageIdSpec, Shell};
-use cargo::util::config::{self, Config, Definition, SslVersionConfig, StringList};
+use cargo::util::config::{self, Config, Definition, JobsConfig, SslVersionConfig, StringList};
use cargo::util::interning::InternedString;
use cargo::util::toml::{self as cargo_toml, TomlDebugInfo, VecStringOrBool as VSOB};
use cargo::CargoResult;
@@ -1651,3 +1651,63 @@ fn debuginfo_parsing() {
.ends_with("could not load config key `profile.dev.debug`"));
}
}
+
+#[cargo_test]
+fn build_jobs_missing() {
+ write_config(
+ "\
+[build]
+",
+ );
+
+ let config = new_config();
+
+ assert!(config
+ .get::<Option<JobsConfig>>("build.jobs")
+ .unwrap()
+ .is_none());
+}
+
+#[cargo_test]
+fn build_jobs_default() {
+ write_config(
+ "\
+[build]
+jobs = \"default\"
+",
+ );
+
+ let config = new_config();
+
+ let a = config
+ .get::<Option<JobsConfig>>("build.jobs")
+ .unwrap()
+ .unwrap();
+
+ match a {
+ JobsConfig::String(v) => assert_eq!(&v, "default"),
+ JobsConfig::Integer(_) => panic!("Did not except an integer."),
+ }
+}
+
+#[cargo_test]
+fn build_jobs_integer() {
+ write_config(
+ "\
+[build]
+jobs = 2
+",
+ );
+
+ let config = new_config();
+
+ let a = config
+ .get::<Option<JobsConfig>>("build.jobs")
+ .unwrap()
+ .unwrap();
+
+ match a {
+ JobsConfig::String(_) => panic!("Did not except an integer."),
+ JobsConfig::Integer(v) => assert_eq!(v, 2),
+ }
+}
diff --git a/src/tools/cargo/tests/testsuite/config_include.rs b/src/tools/cargo/tests/testsuite/config_include.rs
index ae568065a..057c583ae 100644
--- a/src/tools/cargo/tests/testsuite/config_include.rs
+++ b/src/tools/cargo/tests/testsuite/config_include.rs
@@ -6,9 +6,9 @@ use cargo_test_support::{no_such_file_err_msg, project};
#[cargo_test]
fn gated() {
// Requires -Z flag.
- write_config("include='other'");
+ write_config("include='other.toml'");
write_config_at(
- ".cargo/other",
+ ".cargo/other.toml",
"
othervalue = 1
",
@@ -25,13 +25,13 @@ fn simple() {
write_config_at(
".cargo/config",
"
- include = 'other'
+ include = 'other.toml'
key1 = 1
key2 = 2
",
);
write_config_at(
- ".cargo/other",
+ ".cargo/other.toml",
"
key2 = 3
key3 = 4
@@ -84,39 +84,63 @@ fn works_with_cli() {
}
#[cargo_test]
-fn left_to_right() {
- // How it merges multiple includes.
+fn left_to_right_bottom_to_top() {
+ // How it merges multiple nested includes.
write_config_at(
".cargo/config",
"
- include = ['one', 'two']
- primary = 1
+ include = ['left-middle.toml', 'right-middle.toml']
+ top = 1
+ ",
+ );
+ write_config_at(
+ ".cargo/right-middle.toml",
+ "
+ include = 'right-bottom.toml'
+ top = 0
+ right-middle = 0
",
);
write_config_at(
- ".cargo/one",
+ ".cargo/right-bottom.toml",
"
- one = 1
- primary = 2
+ top = -1
+ right-middle = -1
+ right-bottom = -1
",
);
write_config_at(
- ".cargo/two",
+ ".cargo/left-middle.toml",
"
- two = 2
- primary = 3
+ include = 'left-bottom.toml'
+ top = -2
+ right-middle = -2
+ right-bottom = -2
+ left-middle = -2
+ ",
+ );
+ write_config_at(
+ ".cargo/left-bottom.toml",
+ "
+ top = -3
+ right-middle = -3
+ right-bottom = -3
+ left-middle = -3
+ left-bottom = -3
",
);
let config = ConfigBuilder::new().unstable_flag("config-include").build();
- assert_eq!(config.get::<i32>("primary").unwrap(), 1);
- assert_eq!(config.get::<i32>("one").unwrap(), 1);
- assert_eq!(config.get::<i32>("two").unwrap(), 2);
+ assert_eq!(config.get::<i32>("top").unwrap(), 1);
+ assert_eq!(config.get::<i32>("right-middle").unwrap(), 0);
+ assert_eq!(config.get::<i32>("right-bottom").unwrap(), -1);
+ assert_eq!(config.get::<i32>("left-middle").unwrap(), -2);
+ assert_eq!(config.get::<i32>("left-bottom").unwrap(), -3);
}
#[cargo_test]
fn missing_file() {
// Error when there's a missing file.
- write_config("include='missing'");
+ write_config("include='missing.toml'");
let config = ConfigBuilder::new()
.unstable_flag("config-include")
.build_err();
@@ -127,10 +151,10 @@ fn missing_file() {
could not load Cargo configuration
Caused by:
- failed to load config include `missing` from `[..]/.cargo/config`
+ failed to load config include `missing.toml` from `[..]/.cargo/config`
Caused by:
- failed to read configuration file `[..]/.cargo/missing`
+ failed to read configuration file `[..]/.cargo/missing.toml`
Caused by:
{}",
@@ -140,11 +164,29 @@ Caused by:
}
#[cargo_test]
+fn wrong_file_extension() {
+ // Error when it doesn't end with `.toml`.
+ write_config("include='config.png'");
+ let config = ConfigBuilder::new()
+ .unstable_flag("config-include")
+ .build_err();
+ assert_error(
+ config.unwrap_err(),
+ "\
+could not load Cargo configuration
+
+Caused by:
+ expected a config include path ending with `.toml`, but found `config.png` from `[..]/.cargo/config`
+",
+ );
+}
+
+#[cargo_test]
fn cycle() {
// Detects a cycle.
- write_config_at(".cargo/config", "include='one'");
- write_config_at(".cargo/one", "include='two'");
- write_config_at(".cargo/two", "include='config'");
+ write_config_at(".cargo/config.toml", "include='one.toml'");
+ write_config_at(".cargo/one.toml", "include='two.toml'");
+ write_config_at(".cargo/two.toml", "include='config.toml'");
let config = ConfigBuilder::new()
.unstable_flag("config-include")
.build_err();
@@ -154,16 +196,16 @@ fn cycle() {
could not load Cargo configuration
Caused by:
- failed to load config include `one` from `[..]/.cargo/config`
+ failed to load config include `one.toml` from `[..]/.cargo/config.toml`
Caused by:
- failed to load config include `two` from `[..]/.cargo/one`
+ failed to load config include `two.toml` from `[..]/.cargo/one.toml`
Caused by:
- failed to load config include `config` from `[..]/.cargo/two`
+ failed to load config include `config.toml` from `[..]/.cargo/two.toml`
Caused by:
- config `include` cycle detected with path `[..]/.cargo/config`",
+ config `include` cycle detected with path `[..]/.cargo/config.toml`",
);
}
@@ -178,10 +220,10 @@ fn cli_include() {
bar = 2
",
);
- write_config_at(".cargo/config-foo", "foo = 2");
+ write_config_at(".cargo/config-foo.toml", "foo = 2");
let config = ConfigBuilder::new()
.unstable_flag("config-include")
- .config_arg("include='.cargo/config-foo'")
+ .config_arg("include='.cargo/config-foo.toml'")
.build();
assert_eq!(config.get::<i32>("foo").unwrap(), 2);
assert_eq!(config.get::<i32>("bar").unwrap(), 2);
@@ -209,7 +251,7 @@ fn cli_include_failed() {
// Error message when CLI include fails to load.
let config = ConfigBuilder::new()
.unstable_flag("config-include")
- .config_arg("include='foobar'")
+ .config_arg("include='foobar.toml'")
.build_err();
assert_error(
config.unwrap_err(),
@@ -218,10 +260,10 @@ fn cli_include_failed() {
failed to load --config include
Caused by:
- failed to load config include `foobar` from `--config cli option`
+ failed to load config include `foobar.toml` from `--config cli option`
Caused by:
- failed to read configuration file `[..]/foobar`
+ failed to read configuration file `[..]/foobar.toml`
Caused by:
{}",
@@ -235,14 +277,14 @@ fn cli_merge_failed() {
// Error message when CLI include merge fails.
write_config("foo = ['a']");
write_config_at(
- ".cargo/other",
+ ".cargo/other.toml",
"
foo = 'b'
",
);
let config = ConfigBuilder::new()
.unstable_flag("config-include")
- .config_arg("include='.cargo/other'")
+ .config_arg("include='.cargo/other.toml'")
.build_err();
// Maybe this error message should mention it was from an include file?
assert_error(
@@ -251,7 +293,7 @@ fn cli_merge_failed() {
failed to merge --config key `foo` into `[..]/.cargo/config`
Caused by:
- failed to merge config value from `[..]/.cargo/other` into `[..]/.cargo/config`: \
+ failed to merge config value from `[..]/.cargo/other.toml` into `[..]/.cargo/config`: \
expected array, but found string",
);
}
diff --git a/src/tools/cargo/tests/testsuite/cross_compile.rs b/src/tools/cargo/tests/testsuite/cross_compile.rs
index cc9644550..1bc0c277d 100644
--- a/src/tools/cargo/tests/testsuite/cross_compile.rs
+++ b/src/tools/cargo/tests/testsuite/cross_compile.rs
@@ -398,7 +398,7 @@ fn linker() {
"\
[COMPILING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name foo src/foo.rs [..]--crate-type bin \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [CWD]/target/{target}/debug/deps \
--target {target} \
diff --git a/src/tools/cargo/tests/testsuite/custom_target.rs b/src/tools/cargo/tests/testsuite/custom_target.rs
index b7ad4d835..491d3233c 100644
--- a/src/tools/cargo/tests/testsuite/custom_target.rs
+++ b/src/tools/cargo/tests/testsuite/custom_target.rs
@@ -4,6 +4,7 @@ use cargo_test_support::{basic_manifest, project};
use std::fs;
const MINIMAL_LIB: &str = r#"
+#![allow(internal_features)]
#![feature(no_core)]
#![feature(lang_items)]
#![no_core]
@@ -80,6 +81,7 @@ fn custom_target_dependency() {
.file(
"src/lib.rs",
r#"
+ #![allow(internal_features)]
#![feature(no_core)]
#![feature(lang_items)]
#![feature(auto_traits)]
diff --git a/src/tools/cargo/tests/testsuite/directory.rs b/src/tools/cargo/tests/testsuite/directory.rs
index 0e28de039..e72f1f07d 100644
--- a/src/tools/cargo/tests/testsuite/directory.rs
+++ b/src/tools/cargo/tests/testsuite/directory.rs
@@ -188,7 +188,9 @@ fn simple_install_fail() {
.with_status(101)
.with_stderr(
" Installing bar v0.1.0
-error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`
+error: failed to compile `bar v0.1.0`, intermediate artifacts can be found at `[..]`.
+To reuse those artifacts with a future compilation, set the environment variable \
+`CARGO_TARGET_DIR` to that path.
Caused by:
no matching package found
@@ -759,7 +761,9 @@ fn version_missing() {
.with_stderr(
"\
[INSTALLING] bar v0.1.0
-error: failed to compile [..]
+error: failed to compile [..], intermediate artifacts can be found at `[..]`.
+To reuse those artifacts with a future compilation, set the environment variable \
+`CARGO_TARGET_DIR` to that path.
Caused by:
failed to select a version for the requirement `foo = \"^2\"`
diff --git a/src/tools/cargo/tests/testsuite/doc.rs b/src/tools/cargo/tests/testsuite/doc.rs
index 739bcf376..481df8590 100644
--- a/src/tools/cargo/tests/testsuite/doc.rs
+++ b/src/tools/cargo/tests/testsuite/doc.rs
@@ -756,6 +756,7 @@ fn doc_target() {
.file(
"src/lib.rs",
r#"
+ #![allow(internal_features)]
#![feature(no_core, lang_items)]
#![no_core]
@@ -2041,7 +2042,7 @@ fn crate_versions_flag_is_overridden() {
asserts(output_documentation());
}
-#[cargo_test(nightly, reason = "-Zdoctest-in-workspace is unstable")]
+#[cargo_test]
fn doc_test_in_workspace() {
let p = project()
.file(
@@ -2087,8 +2088,7 @@ fn doc_test_in_workspace() {
",
)
.build();
- p.cargo("test -Zdoctest-in-workspace --doc -vv")
- .masquerade_as_nightly_cargo(&["doctest-in-workspace"])
+ p.cargo("test --doc -vv")
.with_stderr_contains("[DOCTEST] crate-a")
.with_stdout_contains(
"
@@ -2096,7 +2096,6 @@ running 1 test
test crate-a/src/lib.rs - (line 1) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]
-
",
)
.with_stderr_contains("[DOCTEST] crate-b")
@@ -2106,7 +2105,98 @@ running 1 test
test crate-b/src/lib.rs - (line 1) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]
+",
+ )
+ .run();
+}
+
+/// This is a test for <https://github.com/rust-lang/rust/issues/46372>.
+/// The `file!()` macro inside of an `include!()` should output
+/// workspace-relative paths, just like it does in other cases.
+#[cargo_test]
+fn doc_test_include_file() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [workspace]
+ members = [
+ "child",
+ ]
+ [package]
+ name = "root"
+ version = "0.1.0"
+ "#,
+ )
+ .file(
+ "src/lib.rs",
+ r#"
+ /// ```
+ /// assert_eq!("src/lib.rs", file!().replace("\\", "/"))
+ /// ```
+ pub mod included {
+ include!(concat!("../", file!(), ".included.rs"));
+ }
+ "#,
+ )
+ .file(
+ "src/lib.rs.included.rs",
+ r#"
+ /// ```
+ /// assert_eq!(1, 1)
+ /// ```
+ pub fn foo() {}
+ "#,
+ )
+ .file(
+ "child/Cargo.toml",
+ r#"
+ [package]
+ name = "child"
+ version = "0.1.0"
+ "#,
+ )
+ .file(
+ "child/src/lib.rs",
+ r#"
+ /// ```
+ /// assert_eq!("child/src/lib.rs", file!().replace("\\", "/"))
+ /// ```
+ pub mod included {
+ include!(concat!("../../", file!(), ".included.rs"));
+ }
+ "#,
+ )
+ .file(
+ "child/src/lib.rs.included.rs",
+ r#"
+ /// ```
+ /// assert_eq!(1, 1)
+ /// ```
+ pub fn foo() {}
+ "#,
+ )
+ .build();
+
+ p.cargo("test --workspace --doc -vv -- --test-threads=1")
+ .with_stderr_contains("[DOCTEST] child")
+ .with_stdout_contains(
+ "
+running 2 tests
+test child/src/../../child/src/lib.rs.included.rs - included::foo (line 2) ... ok
+test child/src/lib.rs - included (line 2) ... ok
+
+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]
+",
+ )
+ .with_stderr_contains("[DOCTEST] root")
+ .with_stdout_contains(
+ "
+running 2 tests
+test src/../src/lib.rs.included.rs - included::foo (line 2) ... ok
+test src/lib.rs - included (line 2) ... ok
+test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]
",
)
.run();
diff --git a/src/tools/cargo/tests/testsuite/features.rs b/src/tools/cargo/tests/testsuite/features.rs
index 848e05677..557fab14a 100644
--- a/src/tools/cargo/tests/testsuite/features.rs
+++ b/src/tools/cargo/tests/testsuite/features.rs
@@ -1937,8 +1937,8 @@ fn nonexistent_required_features() {
}
#[cargo_test]
-fn invalid_feature_names_warning() {
- // Warnings for more restricted feature syntax.
+fn invalid_feature_names_error() {
+ // Errors for more restricted feature syntax.
let p = project()
.file(
"Cargo.toml",
@@ -1948,72 +1948,57 @@ fn invalid_feature_names_warning() {
version = "0.1.0"
[features]
- # Some valid, but unusual names, shouldn't warn.
- "c++17" = []
- "128bit" = []
- "_foo" = []
- "feat-name" = []
- "feat_name" = []
- "foo.bar" = []
-
- # Invalid names.
+ # Invalid start character.
"+foo" = []
- "-foo" = []
- ".foo" = []
- "foo:bar" = []
- "foo?" = []
- "?foo" = []
- "ⒶⒷⒸ" = []
- "a¼" = []
"#,
)
.file("src/lib.rs", "")
.build();
- // Unfortunately the warnings are duplicated due to the Summary being
- // loaded twice (once in the Workspace, and once in PackageRegistry) and
- // Cargo does not have a de-duplication system. This should probably be
- // OK, since I'm not expecting this to affect anyone.
p.cargo("check")
- .with_stderr("\
-[WARNING] invalid character `+` in feature `+foo` in package foo v0.1.0 ([ROOT]/foo), the first character must be a Unicode XID start character or digit (most letters or `_` or `0` to `9`)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `-` in feature `-foo` in package foo v0.1.0 ([ROOT]/foo), the first character must be a Unicode XID start character or digit (most letters or `_` or `0` to `9`)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `.` in feature `.foo` in package foo v0.1.0 ([ROOT]/foo), the first character must be a Unicode XID start character or digit (most letters or `_` or `0` to `9`)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `?` in feature `?foo` in package foo v0.1.0 ([ROOT]/foo), the first character must be a Unicode XID start character or digit (most letters or `_` or `0` to `9`)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `¼` in feature `a¼` in package foo v0.1.0 ([ROOT]/foo), characters must be Unicode XID characters, `+`, or `.` (numbers, `+`, `-`, `_`, `.`, or most letters)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `:` in feature `foo:bar` in package foo v0.1.0 ([ROOT]/foo), characters must be Unicode XID characters, `+`, or `.` (numbers, `+`, `-`, `_`, `.`, or most letters)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `?` in feature `foo?` in package foo v0.1.0 ([ROOT]/foo), characters must be Unicode XID characters, `+`, or `.` (numbers, `+`, `-`, `_`, `.`, or most letters)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `Ⓐ` in feature `ⒶⒷⒸ` in package foo v0.1.0 ([ROOT]/foo), the first character must be a Unicode XID start character or digit (most letters or `_` or `0` to `9`)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `Ⓑ` in feature `ⒶⒷⒸ` in package foo v0.1.0 ([ROOT]/foo), characters must be Unicode XID characters, `+`, or `.` (numbers, `+`, `-`, `_`, `.`, or most letters)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[WARNING] invalid character `Ⓒ` in feature `ⒶⒷⒸ` in package foo v0.1.0 ([ROOT]/foo), characters must be Unicode XID characters, `+`, or `.` (numbers, `+`, `-`, `_`, `.`, or most letters)
-This was previously accepted but is being phased out; it will become a hard error in a future release.
-For more information, see issue #8813 <https://github.com/rust-lang/cargo/issues/8813>, and please leave a comment if this will be a problem for your project.
-[CHECKING] foo v0.1.0 [..]
-[FINISHED] [..]
-")
+ .with_status(101)
+ .with_stderr(
+ "\
+error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
+
+Caused by:
+ invalid character `+` in feature `+foo` in package foo v0.1.0 ([ROOT]/foo), \
+ the first character must be a Unicode XID start character or digit \
+ (most letters or `_` or `0` to `9`)
+",
+ )
+ .run();
+
+ p.change_file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+
+ [features]
+ # Invalid continue character.
+ "a&b" = []
+ "#,
+ );
+
+ p.cargo("check")
+ .with_status(101)
+ .with_stderr(
+ "\
+error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
+
+Caused by:
+ invalid character `&` in feature `a&b` in package foo v0.1.0 ([ROOT]/foo), \
+ characters must be Unicode XID characters, `+`, or `.` \
+ (numbers, `+`, `-`, `_`, `.`, or most letters)
+",
+ )
.run();
}
#[cargo_test]
-fn invalid_feature_names_error() {
+fn invalid_feature_name_slash_error() {
// Errors for more restricted feature syntax.
let p = project()
.file(
diff --git a/src/tools/cargo/tests/testsuite/features2.rs b/src/tools/cargo/tests/testsuite/features2.rs
index 494c83f1e..68fecb863 100644
--- a/src/tools/cargo/tests/testsuite/features2.rs
+++ b/src/tools/cargo/tests/testsuite/features2.rs
@@ -1407,6 +1407,41 @@ workspace: [..]/foo/Cargo.toml
}
#[cargo_test]
+fn edition_2021_workspace_member() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [workspace]
+ members = ["a"]
+ "#,
+ )
+ .file(
+ "a/Cargo.toml",
+ r#"
+ [package]
+ name = "a"
+ version = "0.1.0"
+ edition = "2021"
+ "#,
+ )
+ .file("a/src/lib.rs", "")
+ .build();
+
+ p.cargo("check")
+ .with_stderr(
+ "\
+warning: some crates are on edition 2021 which defaults to `resolver = \"2\"`, but virtual workspaces default to `resolver = \"1\"`
+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
+[CHECKING] a v0.1.0 [..]
+[FINISHED] [..]
+",
+ )
+ .run();
+}
+
+#[cargo_test]
fn resolver_ws_root_and_member() {
// Check when specified in both ws root and member.
let p = project()
diff --git a/src/tools/cargo/tests/testsuite/future_incompat_report.rs b/src/tools/cargo/tests/testsuite/future_incompat_report.rs
index 9f451a64c..4d2c66d17 100644
--- a/src/tools/cargo/tests/testsuite/future_incompat_report.rs
+++ b/src/tools/cargo/tests/testsuite/future_incompat_report.rs
@@ -164,7 +164,7 @@ fn test_multi_crate() {
second-dep = "*"
"#,
)
- .file("src/main.rs", "fn main() {}")
+ .file("src/lib.rs", "")
.build();
for command in &["build", "check", "rustc", "test"] {
diff --git a/src/tools/cargo/tests/testsuite/git.rs b/src/tools/cargo/tests/testsuite/git.rs
index 7c717e967..f60ee978a 100644
--- a/src/tools/cargo/tests/testsuite/git.rs
+++ b/src/tools/cargo/tests/testsuite/git.rs
@@ -3619,3 +3619,71 @@ fn cleans_temp_pack_files() {
p.cargo("generate-lockfile").run();
assert!(!tmp_path.exists());
}
+
+#[cargo_test]
+fn different_user_relative_submodules() {
+ let user1_git_project = git::new("user1/dep1", |project| {
+ project
+ .file("Cargo.toml", &basic_lib_manifest("dep1"))
+ .file("src/lib.rs", "")
+ });
+
+ let user2_git_project = git::new("user2/dep1", |project| {
+ project
+ .file("Cargo.toml", &basic_lib_manifest("dep1"))
+ .file("src/lib.rs", "")
+ });
+ let user2_git_project2 = git::new("user2/dep2", |project| {
+ project
+ .file("Cargo.toml", &basic_lib_manifest("dep1"))
+ .file("src/lib.rs", "")
+ });
+
+ let user2_repo = git2::Repository::open(&user2_git_project.root()).unwrap();
+ let url = "../dep2";
+ git::add_submodule(&user2_repo, url, Path::new("dep2"));
+ git::commit(&user2_repo);
+
+ let user1_repo = git2::Repository::open(&user1_git_project.root()).unwrap();
+ let url = user2_git_project.url();
+ git::add_submodule(&user1_repo, url.as_str(), Path::new("user2/dep1"));
+ git::commit(&user1_repo);
+
+ let project = project()
+ .file(
+ "Cargo.toml",
+ &format!(
+ r#"
+ [package]
+ name = "foo"
+ version = "0.5.0"
+
+ [dependencies.dep1]
+ git = '{}'
+ "#,
+ user1_git_project.url()
+ ),
+ )
+ .file("src/main.rs", &main_file(r#""hello""#, &[]))
+ .build();
+
+ project
+ .cargo("build")
+ .with_stderr(&format!(
+ "\
+[UPDATING] git repository `{}`
+[UPDATING] git submodule `{}`
+[UPDATING] git submodule `{}`
+[COMPILING] dep1 v0.5.0 ({}#[..])
+[COMPILING] foo v0.5.0 ([CWD])
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
+",
+ path2url(&user1_git_project.root()),
+ path2url(&user2_git_project.root()),
+ path2url(&user2_git_project2.root()),
+ path2url(&user1_git_project.root()),
+ ))
+ .run();
+
+ assert!(project.bin("foo").is_file());
+}
diff --git a/src/tools/cargo/tests/testsuite/install.rs b/src/tools/cargo/tests/testsuite/install.rs
index 9b881dfdc..0c7fc5037 100644
--- a/src/tools/cargo/tests/testsuite/install.rs
+++ b/src/tools/cargo/tests/testsuite/install.rs
@@ -58,6 +58,20 @@ fn simple() {
}
#[cargo_test]
+fn toolchain() {
+ pkg("foo", "0.0.1");
+
+ cargo_process("install +nightly")
+ .with_status(101)
+ .with_stderr(
+ "\
+[ERROR] invalid character `+` in package name: `+nightly`
+ Use `cargo +nightly install` if you meant to use the `nightly` toolchain.",
+ )
+ .run();
+}
+
+#[cargo_test]
fn simple_with_message_format() {
pkg("foo", "0.0.1");
@@ -964,7 +978,8 @@ fn compile_failure() {
"\
[ERROR] could not compile `foo` (bin \"foo\") due to previous error
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be \
- found at `[..]target`
+ found at `[..]target`.\nTo reuse those artifacts with a future compilation, \
+ set the environment variable `CARGO_TARGET_DIR` to that path.
",
)
.run();
@@ -1269,7 +1284,8 @@ fn reports_unsuccessful_subcommand_result() {
.run();
cargo_process("fail")
.with_status(101)
- .with_stderr_contains("thread '[..]' panicked at 'explicit panic', [..]")
+ .with_stderr_contains("thread '[..]' panicked at [..]src/main.rs:1:[..]")
+ .with_stderr_contains("[..]explicit panic[..]")
.run();
}
@@ -2250,7 +2266,9 @@ fn failed_install_retains_temp_directory() {
)
.unwrap();
compare::match_contains(
- "error: failed to compile `foo v0.0.1`, intermediate artifacts can be found at `[..]`",
+ "error: failed to compile `foo v0.0.1`, intermediate artifacts can be found at \
+ `[..]`.\nTo reuse those artifacts with a future compilation, set the environment \
+ variable `CARGO_TARGET_DIR` to that path.",
&stderr,
None,
)
@@ -2258,7 +2276,7 @@ fn failed_install_retains_temp_directory() {
// Find the path in the output.
let start = stderr.find("found at `").unwrap() + 10;
- let end = stderr[start..].find('\n').unwrap() - 1;
+ let end = stderr[start..].find('.').unwrap() - 1;
let path = Path::new(&stderr[start..(end + start)]);
assert!(path.exists());
assert!(path.join("release/deps").exists());
diff --git a/src/tools/cargo/tests/testsuite/lockfile_compat.rs b/src/tools/cargo/tests/testsuite/lockfile_compat.rs
index aad8723c3..63148cc07 100644
--- a/src/tools/cargo/tests/testsuite/lockfile_compat.rs
+++ b/src/tools/cargo/tests/testsuite/lockfile_compat.rs
@@ -888,3 +888,81 @@ perhaps a crate was updated and forgotten to be re-vendored?
)
.run();
}
+
+#[cargo_test]
+fn v4_is_unstable() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ &format!(
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#,
+ ),
+ )
+ .file("src/lib.rs", "")
+ .file("Cargo.lock", "version = 4")
+ .build();
+
+ p.cargo("fetch")
+ .with_status(101)
+ .with_stderr(
+ "\
+error: failed to parse lock file at: [CWD]/Cargo.lock
+
+Caused by:
+ lock file version `4` was found, but this version of Cargo does not \
+ understand this lock file, perhaps Cargo needs to be updated?
+",
+ )
+ .run();
+
+ // On nightly, let the user know about the `-Z` flag.
+ p.cargo("fetch")
+ .masquerade_as_nightly_cargo(&["-Znext-lockfile-bump"])
+ .with_status(101)
+ .with_stderr(
+ "\
+error: failed to parse lock file at: [CWD]/Cargo.lock
+
+Caused by:
+ lock file version 4 requires `-Znext-lockfile-bump`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn v4_cannot_be_created_from_scratch() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ &format!(
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#,
+ ),
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ p.cargo("fetch -Znext-lockfile-bump")
+ .masquerade_as_nightly_cargo(&["-Znext-lockfile-bump"])
+ .run();
+
+ let lockfile = r#"# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "foo"
+version = "0.0.1"
+"#;
+
+ let lock = p.read_lockfile();
+ assert_match_exact(lockfile, &lock);
+}
diff --git a/src/tools/cargo/tests/testsuite/main.rs b/src/tools/cargo/tests/testsuite/main.rs
index 170a22667..2c282c0a3 100644
--- a/src/tools/cargo/tests/testsuite/main.rs
+++ b/src/tools/cargo/tests/testsuite/main.rs
@@ -123,6 +123,7 @@ mod rustdoc_extern_html;
mod rustdocflags;
mod rustflags;
mod rustup;
+mod script;
mod search;
mod shell_quoting;
mod source_replacement;
diff --git a/src/tools/cargo/tests/testsuite/profile_config.rs b/src/tools/cargo/tests/testsuite/profile_config.rs
index cf9807964..26104e7e7 100644
--- a/src/tools/cargo/tests/testsuite/profile_config.rs
+++ b/src/tools/cargo/tests/testsuite/profile_config.rs
@@ -267,7 +267,7 @@ fn profile_config_all_options() {
-C panic=abort \
-C lto[..]\
-C codegen-units=2 \
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C debug-assertions=on \
-C overflow-checks=off [..]\
-C rpath [..]\
@@ -437,7 +437,7 @@ fn named_config_profile() {
assert_eq!(p.name, "foo");
assert_eq!(p.codegen_units, Some(2)); // "foo" from config
assert_eq!(p.opt_level, "1"); // "middle" from manifest
- assert_eq!(p.debuginfo.to_option(), Some(TomlDebugInfo::Limited)); // "bar" from config
+ assert_eq!(p.debuginfo.into_inner(), TomlDebugInfo::Limited); // "bar" from config
assert_eq!(p.debug_assertions, true); // "dev" built-in (ignore build-override)
assert_eq!(p.overflow_checks, true); // "dev" built-in (ignore package override)
@@ -446,7 +446,7 @@ fn named_config_profile() {
assert_eq!(bo.name, "foo");
assert_eq!(bo.codegen_units, Some(6)); // "foo" build override from config
assert_eq!(bo.opt_level, "0"); // default to zero
- assert_eq!(bo.debuginfo.to_option(), Some(TomlDebugInfo::Limited)); // SAME as normal
+ assert_eq!(bo.debuginfo.into_inner(), TomlDebugInfo::Limited); // SAME as normal
assert_eq!(bo.debug_assertions, false); // "foo" build override from manifest
assert_eq!(bo.overflow_checks, true); // SAME as normal
@@ -455,7 +455,7 @@ fn named_config_profile() {
assert_eq!(po.name, "foo");
assert_eq!(po.codegen_units, Some(7)); // "foo" package override from config
assert_eq!(po.opt_level, "1"); // SAME as normal
- assert_eq!(po.debuginfo.to_option(), Some(TomlDebugInfo::Limited)); // SAME as normal
+ assert_eq!(po.debuginfo.into_inner(), TomlDebugInfo::Limited); // SAME as normal
assert_eq!(po.debug_assertions, true); // SAME as normal
assert_eq!(po.overflow_checks, false); // "middle" package override from manifest
}
@@ -509,12 +509,13 @@ fn test_with_dev_profile() {
[DOWNLOADING] [..]
[DOWNLOADED] [..]
[COMPILING] somedep v1.0.0
-[RUNNING] `rustc --crate-name somedep [..]-C debuginfo=0[..]
+[RUNNING] `rustc --crate-name somedep [..]
[COMPILING] foo v0.1.0 [..]
-[RUNNING] `rustc --crate-name foo [..]-C debuginfo=0[..]
+[RUNNING] `rustc --crate-name foo [..]
[FINISHED] [..]
[EXECUTABLE] `[..]/target/debug/deps/foo-[..][EXE]`
",
)
+ .with_stdout_does_not_contain("[..] -C debuginfo=0[..]")
.run();
}
diff --git a/src/tools/cargo/tests/testsuite/profile_targets.rs b/src/tools/cargo/tests/testsuite/profile_targets.rs
index 0449e8ab3..a88ca34fd 100644
--- a/src/tools/cargo/tests/testsuite/profile_targets.rs
+++ b/src/tools/cargo/tests/testsuite/profile_targets.rs
@@ -88,11 +88,11 @@ fn profile_selection_build() {
.with_stderr_unordered("\
[COMPILING] bar [..]
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
[COMPILING] bdep [..]
-[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
+[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
[COMPILING] foo [..]
-[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
+[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
@@ -100,6 +100,7 @@ fn profile_selection_build() {
[FINISHED] dev [unoptimized + debuginfo] [..]
"
)
+ .with_stderr_does_not_contain("[..] -C debuginfo=0[..]")
.run();
p.cargo("build -vv")
.with_stderr_unordered(
@@ -154,8 +155,9 @@ fn profile_selection_build_all_targets() {
// `build.rs` is a plugin.
// - Benchmark dependencies are compiled in `dev` mode, which may be
// surprising. See issue rust-lang/cargo#4929.
- // - We make sure that the build dependencies bar, bdep, and build.rs
- // are built with debuginfo=0.
+ // - We make sure that the build dependencies bar, bdep, and build.rs are built with
+ // debuginfo=0; but since we don't pass `-C debuginfo` when it's set to 0, we have to test
+ // explicitly that there's no `-C debuginfo` flag.
//
// - Dependency profiles:
// Pkg Target Profile Reason
@@ -181,24 +183,25 @@ fn profile_selection_build_all_targets() {
[COMPILING] bar [..]
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
+[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
[COMPILING] bdep [..]
-[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
+[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
[COMPILING] foo [..]
-[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
+[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]`
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
-[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]`
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
+[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]`
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
[FINISHED] dev [unoptimized + debuginfo] [..]
"
)
+ .with_stderr_does_not_contain("[..] -C debuginfo=0[..]")
.run();
p.cargo("build -vv")
.with_stderr_unordered(
@@ -315,10 +318,10 @@ fn profile_selection_test() {
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..]
[FINISHED] test [unoptimized + debuginfo] [..]
[RUNNING] `[..]/deps/foo-[..]`
@@ -513,10 +516,10 @@ fn profile_selection_check_all_targets() {
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..]--test [..]
[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]metadata -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
[FINISHED] dev [unoptimized + debuginfo] [..]
@@ -615,11 +618,11 @@ fn profile_selection_check_all_targets_test() {
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]
-[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
-[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..]
+[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
+[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..]--test [..]
[FINISHED] test [unoptimized + debuginfo] [..]
").run();
diff --git a/src/tools/cargo/tests/testsuite/profiles.rs b/src/tools/cargo/tests/testsuite/profiles.rs
index 2d2646fe3..465ab3b99 100644
--- a/src/tools/cargo/tests/testsuite/profiles.rs
+++ b/src/tools/cargo/tests/testsuite/profiles.rs
@@ -66,7 +66,7 @@ fn opt_level_override_0() {
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link[..]\
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
@@ -99,7 +99,7 @@ fn debug_override_1() {
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link[..]\
- -C debuginfo=1 \
+ -C debuginfo=1 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
@@ -136,7 +136,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) {
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level={level}[..]\
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C debug-assertions=on \
-C metadata=[..] \
--out-dir [..] \
@@ -211,7 +211,7 @@ fn top_level_overrides_deps() {
--emit=[..]link \
-C prefer-dynamic \
-C opt-level=1[..]\
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [CWD]/target/release/deps \
-L dependency=[CWD]/target/release/deps`
@@ -219,7 +219,7 @@ fn top_level_overrides_deps() {
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level=1[..]\
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/release/deps \
@@ -467,10 +467,11 @@ fn debug_0_report() {
.with_stderr(
"\
[COMPILING] foo v0.1.0 [..]
-[RUNNING] `rustc --crate-name foo src/lib.rs [..]-C debuginfo=0 [..]
+[RUNNING] `rustc --crate-name foo src/lib.rs [..]
[FINISHED] dev [unoptimized] target(s) in [..]
",
)
+ .with_stderr_does_not_contain("-C debuginfo")
.run();
}
@@ -742,3 +743,42 @@ Caused by:
)
.run();
}
+
+#[cargo_test(nightly, reason = "debug options stabilized in 1.70")]
+fn debug_options_valid() {
+ let build = |option| {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ &format!(
+ r#"
+ [package]
+ name = "foo"
+ authors = []
+ version = "0.0.0"
+
+ [profile.dev]
+ debug = "{option}"
+ "#
+ ),
+ )
+ .file("src/main.rs", "fn main() {}")
+ .build();
+
+ p.cargo("build -v")
+ };
+
+ for (option, cli) in [
+ ("line-directives-only", "line-directives-only"),
+ ("line-tables-only", "line-tables-only"),
+ ("limited", "1"),
+ ("full", "2"),
+ ] {
+ build(option)
+ .with_stderr_contains(&format!("[RUNNING] `rustc [..]-C debuginfo={cli} [..]"))
+ .run();
+ }
+ build("none")
+ .with_stderr_does_not_contain("[..]-C debuginfo[..]")
+ .run();
+}
diff --git a/src/tools/cargo/tests/testsuite/required_features.rs b/src/tools/cargo/tests/testsuite/required_features.rs
index ac6c9d233..88be89fd4 100644
--- a/src/tools/cargo/tests/testsuite/required_features.rs
+++ b/src/tools/cargo/tests/testsuite/required_features.rs
@@ -658,7 +658,9 @@ Consider enabling some of the needed features by passing, e.g., `--features=\"a\
"\
[INSTALLING] foo v0.0.1 ([..])
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be found at \
- `[..]target`
+ `[..]target`.
+To reuse those artifacts with a future compilation, set the environment \
+variable `CARGO_TARGET_DIR` to that path.
Caused by:
target `foo` in package `foo` requires the features: `a`
@@ -678,7 +680,8 @@ Caused by:
"\
[INSTALLING] foo v0.0.1 ([..])
[ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be found at \
- `[..]target`
+ `[..]target`.\nTo reuse those artifacts with a future compilation, set the environment \
+ variable `CARGO_TARGET_DIR` to that path.
Caused by:
target `foo` in package `foo` requires the features: `a`
diff --git a/src/tools/cargo/tests/testsuite/run.rs b/src/tools/cargo/tests/testsuite/run.rs
index aa210d6ae..586502288 100644
--- a/src/tools/cargo/tests/testsuite/run.rs
+++ b/src/tools/cargo/tests/testsuite/run.rs
@@ -777,14 +777,14 @@ fast2",
[COMPILING] bar v0.5.0 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/bar.rs [..]--crate-type lib \
--emit=[..]link[..]\
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [CWD]/target/debug/deps \
-L dependency=[CWD]/target/debug/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name a examples/a.rs [..]--crate-type bin \
--emit=[..]link[..]\
- -C debuginfo=2 \
+ -C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [CWD]/target/debug/examples \
-L dependency=[CWD]/target/debug/deps \
diff --git a/src/tools/cargo/tests/testsuite/rustc.rs b/src/tools/cargo/tests/testsuite/rustc.rs
index 65e0740f8..6e3d69cf7 100644
--- a/src/tools/cargo/tests/testsuite/rustc.rs
+++ b/src/tools/cargo/tests/testsuite/rustc.rs
@@ -18,7 +18,7 @@ fn build_lib_for_foo() {
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
@@ -40,7 +40,7 @@ fn lib() {
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C debug-assertions=off \
-C metadata=[..] \
--out-dir [..] \
@@ -63,12 +63,12 @@ fn build_main_and_allow_unstable_options() {
"\
[COMPILING] {name} v{version} ([CWD])
[RUNNING] `rustc --crate-name {name} src/lib.rs [..]--crate-type lib \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[RUNNING] `rustc --crate-name {name} src/main.rs [..]--crate-type bin \
- --emit=[..]link[..]-C debuginfo=2 \
+ --emit=[..]link[..]-C debuginfo=2 [..]\
-C debug-assertions \
-C metadata=[..] \
--out-dir [..] \
@@ -109,10 +109,10 @@ fn build_with_args_to_one_of_multiple_binaries() {
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]\
- -C debuginfo=2 -C metadata=[..] \
+ -C debuginfo=2 [..]-C metadata=[..] \
--out-dir [..]`
[RUNNING] `rustc --crate-name bar src/bin/bar.rs [..]--crate-type bin --emit=[..]link[..]\
- -C debuginfo=2 -C debug-assertions [..]`
+ -C debuginfo=2 [..]-C debug-assertions [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
@@ -381,9 +381,9 @@ fn build_with_args_to_one_of_multiple_tests() {
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]\
- -C debuginfo=2 -C metadata=[..] \
+ -C debuginfo=2 [..]-C metadata=[..] \
--out-dir [..]`
-[RUNNING] `rustc --crate-name bar tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 \
+[RUNNING] `rustc --crate-name bar tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 [..]\
-C debug-assertions [..]--test[..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
@@ -420,7 +420,7 @@ fn build_foo_with_bar_dependency() {
[COMPILING] bar v0.1.0 ([..])
[RUNNING] `[..] -C debuginfo=2 [..]`
[COMPILING] foo v0.0.1 ([CWD])
-[RUNNING] `[..] -C debuginfo=2 -C debug-assertions [..]`
+[RUNNING] `[..] -C debuginfo=2 [..]-C debug-assertions [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
@@ -478,7 +478,7 @@ fn targets_selected_default() {
// unit test
.with_stderr_does_not_contain(
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
- -C debuginfo=2 --test [..]",
+ -C debuginfo=2 [..]--test [..]",
)
.run();
}
@@ -495,7 +495,7 @@ fn targets_selected_all() {
// unit test
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]\
- -C debuginfo=2 --test [..]",
+ -C debuginfo=2 [..]--test [..]",
)
.run();
}
diff --git a/src/tools/cargo/tests/testsuite/script.rs b/src/tools/cargo/tests/testsuite/script.rs
new file mode 100644
index 000000000..fcf58de69
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/script.rs
@@ -0,0 +1,1184 @@
+use cargo_test_support::basic_manifest;
+use cargo_test_support::registry::Package;
+
+const ECHO_SCRIPT: &str = r#"#!/usr/bin/env cargo
+
+fn main() {
+ let mut args = std::env::args_os();
+ let bin = args.next().unwrap().to_str().unwrap().to_owned();
+ let args = args.collect::<Vec<_>>();
+ println!("bin: {bin}");
+ println!("args: {args:?}");
+}
+
+#[test]
+fn test () {}
+"#;
+
+#[cfg(unix)]
+fn path() -> Vec<std::path::PathBuf> {
+ std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()).collect()
+}
+
+#[cargo_test]
+fn basic_rs() {
+ let p = cargo_test_support::project()
+ .file("echo.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript -v echo.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/echo[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] echo v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/echo[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn basic_path() {
+ let p = cargo_test_support::project()
+ .file("echo", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript -v ./echo")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/echo[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] echo v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/echo[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn basic_cargo_toml() {
+ let p = cargo_test_support::project()
+ .file("src/main.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript -v Cargo.toml")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: target/debug/foo[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[COMPILING] foo v0.0.1 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `target/debug/foo[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn path_required() {
+ let p = cargo_test_support::project()
+ .file("echo", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript -v echo")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stdout("")
+ .with_stderr(
+ "\
+error: no such command: `echo`
+
+<tab>Did you mean `bench`?
+
+<tab>View all installed commands with `cargo --list`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+#[cfg(unix)]
+fn manifest_precedence_over_plugins() {
+ let p = cargo_test_support::project()
+ .file("echo.rs", ECHO_SCRIPT)
+ .executable(std::path::Path::new("path-test").join("cargo-echo.rs"), "")
+ .build();
+
+ // With path - fmt is there with known description
+ let mut path = path();
+ path.push(p.root().join("path-test"));
+ let path = std::env::join_paths(path.iter()).unwrap();
+
+ p.cargo("-Zscript -v echo.rs")
+ .env("PATH", &path)
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/echo[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] echo v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/echo[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+#[cfg(unix)]
+fn warn_when_plugin_masks_manifest_on_stable() {
+ let p = cargo_test_support::project()
+ .file("echo.rs", ECHO_SCRIPT)
+ .executable(std::path::Path::new("path-test").join("cargo-echo.rs"), "")
+ .build();
+
+ let mut path = path();
+ path.push(p.root().join("path-test"));
+ let path = std::env::join_paths(path.iter()).unwrap();
+
+ p.cargo("-v echo.rs")
+ .env("PATH", &path)
+ .with_stdout("")
+ .with_stderr(
+ "\
+warning: external subcommand `echo.rs` has the appearance of a manfiest-command
+This was previously accepted but will be phased out when `-Zscript` is stabilized.
+For more information, see issue #12207 <https://github.com/rust-lang/cargo/issues/12207>.
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn requires_nightly() {
+ let p = cargo_test_support::project()
+ .file("echo.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-v echo.rs")
+ .with_status(101)
+ .with_stdout("")
+ .with_stderr(
+ "\
+error: running `echo.rs` requires `-Zscript`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn requires_z_flag() {
+ let p = cargo_test_support::project()
+ .file("echo.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-v echo.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stdout("")
+ .with_stderr(
+ "\
+error: running `echo.rs` requires `-Zscript`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn clean_output_with_edition() {
+ let script = r#"#!/usr/bin/env cargo
+
+//! ```cargo
+//! [package]
+//! edition = "2018"
+//! ```
+
+fn main() {
+ println!("Hello world!");
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"Hello world!
+"#,
+ )
+ .with_stderr(
+ "\
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn warning_without_edition() {
+ let script = r#"#!/usr/bin/env cargo
+
+//! ```cargo
+//! [package]
+//! ```
+
+fn main() {
+ println!("Hello world!");
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"Hello world!
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn rebuild() {
+ let script = r#"#!/usr/bin/env cargo-eval
+
+fn main() {
+ let msg = option_env!("_MESSAGE").unwrap_or("undefined");
+ println!("msg = {}", msg);
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"msg = undefined
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+
+ // Verify we don't rebuild
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"msg = undefined
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+
+ // Verify we do rebuild
+ p.cargo("-Zscript -v script.rs")
+ .env("_MESSAGE", "hello")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"msg = hello
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn use_script_config() {
+ let script = ECHO_SCRIPT;
+ let _ = cargo_test_support::project()
+ .at("script")
+ .file("script.rs", script)
+ .build();
+
+ let p = cargo_test_support::project()
+ .file(
+ ".cargo/config",
+ r#"
+[build]
+rustc = "non-existent-rustc"
+"#,
+ )
+ .file("script.rs", script)
+ .build();
+
+ // Verify the config is bad
+ p.cargo("-Zscript script.rs -NotAnArg")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stderr_contains(
+ "\
+[ERROR] could not execute process `non-existent-rustc -vV` (never executed)
+",
+ )
+ .run();
+
+ // Verify that the config isn't used
+ p.cargo("-Zscript ../script/script.rs -NotAnArg")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: ["-NotAnArg"]
+"#,
+ )
+ .run();
+}
+
+#[cargo_test]
+fn default_programmatic_verbosity() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript script.rs -NotAnArg")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: ["-NotAnArg"]
+"#,
+ )
+ .with_stderr(
+ "\
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn quiet() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -q script.rs -NotAnArg")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: ["-NotAnArg"]
+"#,
+ )
+ .with_stderr(
+ "\
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_line_numbering_preserved() {
+ let script = r#"#!/usr/bin/env cargo
+
+fn main() {
+ println!("line: {}", line!());
+}
+"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"line: 4
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_escaped_hyphen_arg() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v -- script.rs -NotAnArg")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: ["-NotAnArg"]
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] -NotAnArg`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_unescaped_hyphen_arg() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs -NotAnArg")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: ["-NotAnArg"]
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] -NotAnArg`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_same_flags() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs --help")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: ["--help"]
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] --help`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_name_has_weird_chars() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("s-h.w§c!.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v s-h.w§c!.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/s-h-w-c-[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ r#"[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] s-h-w-c- v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/s-h-w-c-[EXE]`
+"#,
+ )
+ .run();
+}
+
+#[cargo_test]
+fn script_like_dir() {
+ let p = cargo_test_support::project()
+ .file("script.rs/foo", "something")
+ .build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stderr(
+ "\
+error: manifest path `script.rs` is a directory but expected a file
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn missing_script_rs() {
+ let p = cargo_test_support::project().build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stderr(
+ "\
+[ERROR] manifest path `script.rs` does not exist
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+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"
+//! ```
+
+fn main() {
+ println!("Hello world!");
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs --help")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"Hello world!
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[UPDATING] `dummy-registry` index
+[DOWNLOADING] crates ...
+[DOWNLOADED] script v1.0.0 (registry `dummy-registry`)
+[COMPILING] script v1.0.0
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] --help`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_path_dep() {
+ let script = r#"#!/usr/bin/env cargo
+
+//! ```cargo
+//! [dependencies]
+//! bar.path = "./bar"
+//! ```
+
+fn main() {
+ println!("Hello world!");
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .file("src/lib.rs", "pub fn foo() {}")
+ .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
+
+ p.cargo("-Zscript -v script.rs --help")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"Hello world!
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] --help`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_no_build_rs() {
+ let script = r#"#!/usr/bin/env cargo
+
+fn main() {
+ println!("Hello world!");
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .file("build.rs", "broken")
+ .build();
+
+ p.cargo("-Zscript -v script.rs --help")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"Hello world!
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] --help`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn test_no_autobins() {
+ let script = r#"#!/usr/bin/env cargo
+
+fn main() {
+ println!("Hello world!");
+}"#;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .file("src/bin/not-script/main.rs", "fn main() {}")
+ .build();
+
+ p.cargo("-Zscript -v script.rs --help")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"Hello world!
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE] --help`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn implicit_target_dir() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [ROOT]/home/.cargo/target/[..]/debug/script[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[ROOT]/home/.cargo/target/[..]/debug/script[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn no_local_lockfile() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+ let local_lockfile_path = p.root().join("Cargo.lock");
+
+ assert!(!local_lockfile_path.exists());
+
+ p.cargo("-Zscript -v script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [ROOT]/home/.cargo/target/[..]/debug/script[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[ROOT]/home/.cargo/target/[..]/debug/script[EXE]`
+",
+ )
+ .run();
+
+ assert!(!local_lockfile_path.exists());
+}
+
+#[cargo_test]
+fn cmd_check_requires_nightly() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("check --manifest-path script.rs")
+ .with_status(101)
+ .with_stdout("")
+ .with_stderr(
+ "\
+error: embedded manifest `[ROOT]/foo/script.rs` requires `-Zscript`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_check_requires_z_flag() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("check --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stdout("")
+ .with_stderr(
+ "\
+error: embedded manifest `[ROOT]/foo/script.rs` requires `-Zscript`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_check_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript check --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[CHECKING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_check_with_missing_script_rs() {
+ let p = cargo_test_support::project().build();
+
+ p.cargo("-Zscript check --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[ERROR] manifest path `script.rs` does not exist
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_check_with_missing_script() {
+ let p = cargo_test_support::project().build();
+
+ p.cargo("-Zscript check --manifest-path script")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_status(101)
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[ERROR] the manifest-path must be a path to a Cargo.toml file
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_build_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript build --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_test_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript test --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "
+running 1 test
+test test ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [..]s
+
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] test [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] unittests script.rs ([..])
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_clean_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ // Ensure there is something to clean
+ p.cargo("-Zscript script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .run();
+
+ p.cargo("-Zscript clean --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_generate_lockfile_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript generate-lockfile --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_metadata_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript metadata --manifest-path script.rs --format-version=1")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_json(
+ r#"
+ {
+ "packages": [
+ {
+ "authors": [
+ ],
+ "categories": [],
+ "default_run": null,
+ "name": "script",
+ "version": "0.0.0",
+ "id": "script[..]",
+ "keywords": [],
+ "source": null,
+ "dependencies": [],
+ "edition": "[..]",
+ "license": null,
+ "license_file": null,
+ "links": null,
+ "description": null,
+ "readme": null,
+ "repository": null,
+ "rust_version": null,
+ "homepage": null,
+ "documentation": null,
+ "homepage": null,
+ "documentation": null,
+ "targets": [
+ {
+ "kind": [
+ "bin"
+ ],
+ "crate_types": [
+ "bin"
+ ],
+ "doc": true,
+ "doctest": false,
+ "test": true,
+ "edition": "[..]",
+ "name": "script",
+ "src_path": "[..]/script.rs"
+ }
+ ],
+ "features": {},
+ "manifest_path": "[..]script.rs",
+ "metadata": null,
+ "publish": []
+ }
+ ],
+ "workspace_members": ["script 0.0.0 (path+file:[..]foo)"],
+ "workspace_default_members": ["script 0.0.0 (path+file:[..]foo)"],
+ "resolve": {
+ "nodes": [
+ {
+ "dependencies": [],
+ "deps": [],
+ "features": [],
+ "id": "script 0.0.0 (path+file:[..]foo)"
+ }
+ ],
+ "root": "script 0.0.0 (path+file:[..]foo)"
+ },
+ "target_directory": "[ROOT]/home/.cargo/target/[..]",
+ "version": 1,
+ "workspace_root": "[..]/foo",
+ "metadata": null
+ }"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_read_manifest_with_embedded() {
+ let script = ECHO_SCRIPT;
+ let p = cargo_test_support::project()
+ .file("script.rs", script)
+ .build();
+
+ p.cargo("-Zscript read-manifest --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_json(
+ r#"
+{
+ "authors": [
+ ],
+ "categories": [],
+ "default_run": null,
+ "name":"script",
+ "readme": null,
+ "homepage": null,
+ "documentation": null,
+ "repository": null,
+ "rust_version": null,
+ "version":"0.0.0",
+ "id":"script[..]0.0.0[..](path+file://[..]/foo)",
+ "keywords": [],
+ "license": null,
+ "license_file": null,
+ "links": null,
+ "description": null,
+ "edition": "[..]",
+ "source":null,
+ "dependencies":[],
+ "targets":[{
+ "kind":["bin"],
+ "crate_types":["bin"],
+ "doc": true,
+ "doctest": false,
+ "test": true,
+ "edition": "[..]",
+ "name":"script",
+ "src_path":"[..]/script.rs"
+ }],
+ "features":{},
+ "manifest_path":"[..]script.rs",
+ "metadata": null,
+ "publish": []
+}"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_run_with_embedded() {
+ let p = cargo_test_support::project()
+ .file("script.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript run --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ r#"bin: [..]/debug/script[EXE]
+args: []
+"#,
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+[COMPILING] script v0.0.0 ([ROOT]/foo)
+[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
+[RUNNING] `[..]/debug/script[EXE]`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_tree_with_embedded() {
+ let p = cargo_test_support::project()
+ .file("script.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript tree --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "\
+script v0.0.0 ([ROOT]/foo)
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_update_with_embedded() {
+ let p = cargo_test_support::project()
+ .file("script.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript update --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_stdout(
+ "\
+",
+ )
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn cmd_verify_project_with_embedded() {
+ let p = cargo_test_support::project()
+ .file("script.rs", ECHO_SCRIPT)
+ .build();
+
+ p.cargo("-Zscript verify-project --manifest-path script.rs")
+ .masquerade_as_nightly_cargo(&["script"])
+ .with_json(r#"{"success":"true"}"#)
+ .with_stderr(
+ "\
+[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
+",
+ )
+ .run();
+}
diff --git a/src/tools/cargo/tests/testsuite/test.rs b/src/tools/cargo/tests/testsuite/test.rs
index add0a991f..6a062cfb6 100644
--- a/src/tools/cargo/tests/testsuite/test.rs
+++ b/src/tools/cargo/tests/testsuite/test.rs
@@ -387,8 +387,9 @@ test test_hello ... FAILED
failures:
---- test_hello stdout ----
-[..]thread '[..]' panicked at 'assertion failed:[..]",
+[..]thread '[..]' panicked at [..]",
)
+ .with_stdout_contains("[..]assertion failed[..]")
.with_stdout_contains("[..]`(left == right)`[..]")
.with_stdout_contains("[..]left: `\"hello\"`,[..]")
.with_stdout_contains("[..]right: `\"nope\"`[..]")
@@ -437,10 +438,10 @@ test test_hello ... FAILED
failures:
---- test_hello stdout ----
-[..]thread '[..]' panicked at 'assertion failed: false', \
- tests/footest.rs:1[..]
+[..]thread '[..]' panicked at [..]tests/footest.rs:1:[..]
",
)
+ .with_stdout_contains("[..]assertion failed[..]")
.with_stdout_contains(
"\
failures:
@@ -473,10 +474,10 @@ test test_hello ... FAILED
failures:
---- test_hello stdout ----
-[..]thread '[..]' panicked at 'assertion failed: false', \
- src/lib.rs:1[..]
+[..]thread '[..]' panicked at [..]src/lib.rs:1:[..]
",
)
+ .with_stdout_contains("[..]assertion failed[..]")
.with_stdout_contains(
"\
failures: