From 4b1fc8800d7e32df7c2c2988292a157969b8efaa Mon Sep 17 00:00:00 2001 From: LuuuX Date: Wed, 21 Feb 2024 13:12:50 +0800 Subject: [PATCH] Add two tests to make sure fixup --- .../in/.cargo/config.toml | 5 +++ .../in/Cargo.toml | 5 +++ .../in/src/lib.rs | 0 .../in/vendor/aa/.cargo-checksum.json | 1 + .../in/vendor/aa/Cargo.toml | 5 +++ .../in/vendor/aa/src/lib.rs | 0 .../mod.rs | 35 +++++++++++++++++++ .../out/Cargo.toml | 8 +++++ .../stderr.log | 11 ++++++ .../stdout.log | 0 .../in/.cargo/config.toml | 5 +++ .../in/Cargo.toml | 5 +++ .../in/src/lib.rs | 0 .../in/vendor/aa/.cargo-checksum.json | 1 + .../in/vendor/aa/Cargo.toml | 5 +++ .../in/vendor/aa/src/lib.rs | 0 .../mod.rs | 23 ++++++++++++ .../out/Cargo.toml | 5 +++ .../stderr.log | 1 + .../stdout.log | 0 tests/testsuite/cargo_add/mod.rs | 2 ++ 21 files changed, 117 insertions(+) create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/src/lib.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log create mode 100644 tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml new file mode 100644 index 000000000000..77765fb2c261 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/.cargo/config.toml @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "./vendor" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml new file mode 100644 index 000000000000..cc2e9e1008a3 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json new file mode 100644 index 000000000000..6b05e7794811 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{}} \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml new file mode 100644 index 000000000000..4ccb59396b64 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "aa" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/vendor/aa/src/lib.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs new file mode 100644 index 000000000000..e4efa7b610da --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/mod.rs @@ -0,0 +1,35 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::current_dir; +use cargo_test_support::file; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + cargo_test_support::registry::alt_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", &[]) + .alternative(true) + .publish(); + + let project = Project::from_template(current_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("linked_hash_map --registry alternative") + .current_dir(cwd) + .assert() + .success() + .stdout_matches(file!["stdout.log"]) + .stderr_matches(file!["stderr.log"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml new file mode 100644 index 000000000000..1fe8332c14ea --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/out/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" + +[dependencies] +linked-hash-map = { version = "0.5.4", registry = "alternative" } diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log new file mode 100644 index 000000000000..004713758cc8 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stderr.log @@ -0,0 +1,11 @@ + Updating `alternative` index +warning: translating `linked_hash_map` to `linked-hash-map` + Adding linked-hash-map v0.5.4 to dependencies + Features: + - clippy + - heapsize + - heapsize_impl + - nightly + - serde + - serde_impl + - serde_test diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml new file mode 100644 index 000000000000..77765fb2c261 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/.cargo/config.toml @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "./vendor" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml new file mode 100644 index 000000000000..cc2e9e1008a3 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json new file mode 100644 index 000000000000..6b05e7794811 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{}} \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml new file mode 100644 index 000000000000..4ccb59396b64 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "aa" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/src/lib.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/vendor/aa/src/lib.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs new file mode 100644 index 000000000000..e3ef32f9d63c --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/mod.rs @@ -0,0 +1,23 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::current_dir; +use cargo_test_support::file; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +#[cargo_test] +fn case() { + let project = Project::from_template(current_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("cbindgen") + .current_dir(cwd) + .assert() + .failure() + .stdout_matches(file!["stdout.log"]) + .stderr_matches(file!["stderr.log"]); + + assert_ui().subset_matches(current_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml new file mode 100644 index 000000000000..cc2e9e1008a3 --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/out/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" \ No newline at end of file diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log new file mode 100644 index 000000000000..fbe4bffe918a --- /dev/null +++ b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stderr.log @@ -0,0 +1 @@ +error: the crate `cbindgen` could not be found in registry index. diff --git a/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log b/tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index 949f3a28297e..bf52f6e7f510 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -1,5 +1,7 @@ mod add_basic; mod add_multiple; +mod add_no_vendored_package_with_alter_registry; +mod add_no_vendored_package_with_vendor; mod add_normalized_name_external; mod add_toolchain; mod build;