Skip to content

Commit 7b9d3f5

Browse files
committed
Add tests to ensure this issue is fixed
1 parent e1ebce1 commit 7b9d3f5

File tree

13 files changed

+148
-0
lines changed

13 files changed

+148
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[workspace]
2+
3+
[package]
4+
name = "cargo-list-test-fixture"
5+
version = "0.0.0"

tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/in/src/lib.rs

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
use cargo_test_support::compare::assert_ui;
2+
use cargo_test_support::paths;
3+
use cargo_test_support::prelude::*;
4+
use cargo_test_support::ProjectBuilder;
5+
6+
use cargo_test_support::curr_dir;
7+
8+
#[cargo_test]
9+
fn case() {
10+
cargo_test_support::registry::alt_init();
11+
cargo_test_support::registry::Package::new("linked-hash-map", "0.5.4")
12+
.feature("clippy", &[])
13+
.feature("heapsize", &[])
14+
.feature("heapsize_impl", &[])
15+
.feature("nightly", &[])
16+
.feature("serde", &[])
17+
.feature("serde_impl", &[])
18+
.feature("serde_test", &[])
19+
.alternative(true)
20+
.publish();
21+
22+
let project = ProjectBuilder::new(paths::root().join("in"))
23+
.file(
24+
".cargo/config.toml",
25+
r#"[source.crates-io]
26+
replace-with = "vendored-sources"
27+
28+
[source.vendored-sources]
29+
directory = "./vendor"
30+
"#,
31+
)
32+
.file("src/lib.rs", "")
33+
.file(
34+
"Cargo.toml",
35+
r#"[workspace]
36+
37+
[package]
38+
name = "cargo-list-test-fixture"
39+
version = "0.0.0"
40+
"#,
41+
)
42+
.build();
43+
let project_root = project.root();
44+
let cwd = &project_root;
45+
46+
snapbox::cmd::Command::cargo_ui()
47+
.arg("add")
48+
.arg_line("linked_hash_map --registry alternative")
49+
.current_dir(cwd)
50+
.assert()
51+
.success()
52+
.stdout_matches_path(curr_dir!().join("stdout.log"))
53+
.stderr_matches_path(curr_dir!().join("stderr.log"));
54+
55+
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
3+
[package]
4+
name = "cargo-list-test-fixture"
5+
version = "0.0.0"
6+
7+
[dependencies]
8+
linked-hash-map = { version = "0.5.4", registry = "alternative" }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Updating `alternative` index
2+
warning: translating `linked_hash_map` to `linked-hash-map`
3+
Adding linked-hash-map v0.5.4 to dependencies.
4+
Features:
5+
- clippy
6+
- heapsize
7+
- heapsize_impl
8+
- nightly
9+
- serde
10+
- serde_impl
11+
- serde_test

tests/testsuite/cargo_add/add_no_vendored_package_with_alter_registry/stdout.log

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[workspace]
2+
3+
[package]
4+
name = "cargo-list-test-fixture"
5+
version = "0.0.0"

tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/in/src/lib.rs

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
use cargo_test_support::compare::assert_ui;
2+
use cargo_test_support::paths;
3+
use cargo_test_support::prelude::*;
4+
use cargo_test_support::ProjectBuilder;
5+
6+
use cargo_test_support::curr_dir;
7+
8+
#[cargo_test]
9+
fn case() {
10+
let project = ProjectBuilder::new(paths::root().join("in"))
11+
.file(
12+
".cargo/config.toml",
13+
r#"[source.crates-io]
14+
replace-with = "vendored-sources"
15+
16+
[source.vendored-sources]
17+
directory = "./vendor"
18+
"#,
19+
)
20+
.file("vendor/aa/src/lib.rs", "")
21+
.file("vendor/aa/.cargo-checksum.json", "{\"files\":{}}")
22+
.file(
23+
"vendor/aa/Cargo.toml",
24+
r#"[workspace]
25+
26+
[package]
27+
name = "aa"
28+
version = "0.0.0"
29+
"#,
30+
)
31+
.file("src/lib.rs", "")
32+
.file(
33+
"Cargo.toml",
34+
r#"[workspace]
35+
36+
[package]
37+
name = "cargo-list-test-fixture"
38+
version = "0.0.0"
39+
"#,
40+
)
41+
.build();
42+
let project_root = project.root();
43+
let cwd = &project_root;
44+
45+
snapbox::cmd::Command::cargo_ui()
46+
.arg("add")
47+
.arg_line("cbindgen")
48+
.current_dir(cwd)
49+
.assert()
50+
.failure()
51+
.stdout_matches_path(curr_dir!().join("stdout.log"))
52+
.stderr_matches_path(curr_dir!().join("stderr.log"));
53+
54+
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[workspace]
2+
3+
[package]
4+
name = "cargo-list-test-fixture"
5+
version = "0.0.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
error: the crate `cbindgen` could not be found in registry index.

tests/testsuite/cargo_add/add_no_vendored_package_with_vendor/stdout.log

Whitespace-only changes.

tests/testsuite/cargo_add/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
mod add_basic;
22
mod add_multiple;
3+
mod add_no_vendored_package_with_alter_registry;
4+
mod add_no_vendored_package_with_vendor;
35
mod add_normalized_name_external;
46
mod add_toolchain;
57
mod build;

0 commit comments

Comments
 (0)