Skip to content

Commit 9ac3032

Browse files
committed
Add not overwrite testcase for cargo add --public
1 parent 7c8d997 commit 9ac3032

File tree

12 files changed

+117
-4
lines changed

12 files changed

+117
-4
lines changed

tests/testsuite/cargo_add/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,11 @@ mod namever;
6565
mod no_args;
6666
mod no_default_features;
6767
mod no_optional;
68+
mod no_public;
6869
mod offline_empty_cache;
6970
mod optional;
7071
mod overwrite_default_features;
7172
mod overwrite_default_features_with_no_default_features;
72-
mod overwrite_no_public;
73-
mod overwrite_no_public_with_public;
74-
mod overwrite_public;
75-
mod overwrite_public_with_no_public;
7673
mod overwrite_features;
7774
mod overwrite_git_with_path;
7875
mod overwrite_inherit_features_noop;
@@ -85,11 +82,15 @@ mod overwrite_no_default_features;
8582
mod overwrite_no_default_features_with_default_features;
8683
mod overwrite_no_optional;
8784
mod overwrite_no_optional_with_optional;
85+
mod overwrite_no_public;
86+
mod overwrite_no_public_with_public;
8887
mod overwrite_optional;
8988
mod overwrite_optional_with_no_optional;
9089
mod overwrite_path_noop;
9190
mod overwrite_path_with_version;
9291
mod overwrite_preserves_inline_table;
92+
mod overwrite_public;
93+
mod overwrite_public_with_no_public;
9394
mod overwrite_rename_with_no_rename;
9495
mod overwrite_rename_with_rename;
9596
mod overwrite_rename_with_rename_noop;
@@ -107,6 +108,7 @@ mod preserve_dep_std_table;
107108
mod preserve_features_table;
108109
mod preserve_sorted;
109110
mod preserve_unsorted;
111+
mod public;
110112
mod quiet;
111113
mod registry;
112114
mod rename;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cargo-features = ["public-dependency"]
2+
[workspace]
3+
4+
[package]
5+
name = "cargo-list-test-fixture"
6+
version = "0.0.0"

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

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use cargo_test_support::compare::assert_ui;
2+
use cargo_test_support::prelude::*;
3+
use cargo_test_support::Project;
4+
5+
use cargo_test_support::curr_dir;
6+
7+
#[cargo_test]
8+
fn case() {
9+
cargo_test_support::registry::init();
10+
for name in ["my-package1", "my-package2"] {
11+
for ver in [
12+
"0.1.1+my-package",
13+
"0.2.0+my-package",
14+
"0.2.3+my-package",
15+
"0.4.1+my-package",
16+
"20.0.0+my-package",
17+
"99999.0.0+my-package",
18+
"99999.0.0-alpha.1+my-package",
19+
] {
20+
cargo_test_support::registry::Package::new(name, ver).publish();
21+
}
22+
}
23+
24+
let project = Project::from_template(curr_dir!().join("in"));
25+
let project_root = project.root();
26+
let cwd = &project_root;
27+
28+
snapbox::cmd::Command::cargo_ui()
29+
.arg("add")
30+
.arg_line("my-package1 my-package2@0.4.1 --no-public")
31+
.current_dir(cwd)
32+
.masquerade_as_nightly_cargo(&["public-dependency"])
33+
.assert()
34+
.success()
35+
.stdout_matches_path(curr_dir!().join("stdout.log"))
36+
.stderr_matches_path(curr_dir!().join("stderr.log"));
37+
38+
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
39+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cargo-features = ["public-dependency"]
2+
[workspace]
3+
4+
[package]
5+
name = "cargo-list-test-fixture"
6+
version = "0.0.0"
7+
8+
[dependencies]
9+
my-package1 = "99999.0.0"
10+
my-package2 = "0.4.1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Updating `dummy-registry` index
2+
Adding my-package1 v99999.0.0 to dependencies.
3+
Adding my-package2 v0.4.1 to dependencies.

tests/testsuite/cargo_add/no_public/stdout.log

Whitespace-only changes.

tests/testsuite/cargo_add/public/in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../add-basic.in
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use cargo_test_support::compare::assert_ui;
2+
use cargo_test_support::prelude::*;
3+
use cargo_test_support::Project;
4+
5+
use cargo_test_support::curr_dir;
6+
7+
#[cargo_test]
8+
fn case() {
9+
cargo_test_support::registry::init();
10+
for name in ["my-package1", "my-package2"] {
11+
for ver in [
12+
"0.1.1+my-package",
13+
"0.2.0+my-package",
14+
"0.2.3+my-package",
15+
"0.4.1+my-package",
16+
"20.0.0+my-package",
17+
"99999.0.0+my-package",
18+
"99999.0.0-alpha.1+my-package",
19+
] {
20+
cargo_test_support::registry::Package::new(name, ver).publish();
21+
}
22+
}
23+
24+
let project = Project::from_template(curr_dir!().join("in"));
25+
let project_root = project.root();
26+
let cwd = &project_root;
27+
28+
snapbox::cmd::Command::cargo_ui()
29+
.arg("add")
30+
.arg_line("my-package1 my-package2@0.4.1 --public")
31+
.current_dir(cwd)
32+
.masquerade_as_nightly_cargo(&["public-dependency"])
33+
.assert()
34+
.success()
35+
.stdout_matches_path(curr_dir!().join("stdout.log"))
36+
.stderr_matches_path(curr_dir!().join("stderr.log"));
37+
38+
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
39+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cargo-features = ["public-dependency"]
2+
[workspace]
3+
4+
[package]
5+
name = "cargo-list-test-fixture"
6+
version = "0.0.0"
7+
8+
[dependencies]
9+
my-package1 = { version = "99999.0.0", public = true }
10+
my-package2 = { version = "0.4.1", public = true }

0 commit comments

Comments
 (0)