Skip to content

Commit

Permalink
Add tests to ensure this issue is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
LuuuXXX committed Jan 31, 2024
1 parent e1ebce1 commit 7b9d3f5
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]

[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::ProjectBuilder;

use cargo_test_support::curr_dir;

#[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 = ProjectBuilder::new(paths::root().join("in"))
.file(
".cargo/config.toml",
r#"[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "./vendor"
"#,
)
.file("src/lib.rs", "")
.file(
"Cargo.toml",
r#"[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
"#,
)
.build();
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_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));

assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
}
Original file line number Diff line number Diff line change
@@ -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" }
Original file line number Diff line number Diff line change
@@ -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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]

[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::paths;
use cargo_test_support::prelude::*;
use cargo_test_support::ProjectBuilder;

use cargo_test_support::curr_dir;

#[cargo_test]
fn case() {
let project = ProjectBuilder::new(paths::root().join("in"))
.file(
".cargo/config.toml",
r#"[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "./vendor"
"#,
)
.file("vendor/aa/src/lib.rs", "")
.file("vendor/aa/.cargo-checksum.json", "{\"files\":{}}")
.file(
"vendor/aa/Cargo.toml",
r#"[workspace]
[package]
name = "aa"
version = "0.0.0"
"#,
)
.file("src/lib.rs", "")
.file(
"Cargo.toml",
r#"[workspace]
[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
"#,
)
.build();
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_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));

assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]

[package]
name = "cargo-list-test-fixture"
version = "0.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
error: the crate `cbindgen` could not be found in registry index.
Empty file.
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_add/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 7b9d3f5

Please sign in to comment.