Skip to content

Commit f88a44a

Browse files
committed
Auto merge of #13108 - linyihai:clean-optionals-tests, r=epage
chore(test): remove unnecesary packages and versions for `optionals` tests ### What does this PR try to resolve? This PR was inspired by #13046 (comment) and #12189. There is unnecessary to keep more pacakages and versions on test case and the more pacakage added, the more test time and CI resource taken up. And this PR also fixed a issue that `overwrite_optional_with_optional` had not been added to `tests/testsuite/cargo_add/mod.rs`. ### How should we test and review this PR? ### Additional information
2 parents 9e9349d + b7b036f commit f88a44a

File tree

25 files changed

+30
-129
lines changed

25 files changed

+30
-129
lines changed

tests/testsuite/cargo_add/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ mod overwrite_no_public;
8787
mod overwrite_no_public_with_public;
8888
mod overwrite_optional;
8989
mod overwrite_optional_with_no_optional;
90+
mod overwrite_optional_with_optional;
9091
mod overwrite_path_noop;
9192
mod overwrite_path_with_version;
9293
mod overwrite_preserves_inline_table;

tests/testsuite/cargo_add/no_optional/mod.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,15 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
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-
}
10+
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
2311

2412
let project = Project::from_template(curr_dir!().join("in"));
2513
let project_root = project.root();
2614
let cwd = &project_root;
2715

2816
snapbox::cmd::Command::cargo_ui()
2917
.arg("add")
30-
.arg_line("my-package1 [email protected] --no-optional")
18+
.arg_line("my-package --no-optional")
3119
.current_dir(cwd)
3220
.assert()
3321
.success()

tests/testsuite/cargo_add/no_optional/out/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = "99999.0.0"
9-
my-package2 = "0.4.1"
8+
my-package = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Updating `dummy-registry` index
2-
Adding my-package1 v99999.0.0 to dependencies.
3-
Adding my-package2 v0.4.1 to dependencies.
2+
Adding my-package v0.1.0 to dependencies.

tests/testsuite/cargo_add/optional/mod.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,15 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
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-
}
10+
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
2311

2412
let project = Project::from_template(curr_dir!().join("in"));
2513
let project_root = project.root();
2614
let cwd = &project_root;
2715

2816
snapbox::cmd::Command::cargo_ui()
2917
.arg("add")
30-
.arg_line("my-package1 [email protected] --optional")
18+
.arg_line("my-package --optional")
3119
.current_dir(cwd)
3220
.assert()
3321
.success()

tests/testsuite/cargo_add/optional/out/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = { version = "99999.0.0", optional = true }
9-
my-package2 = { version = "0.4.1", optional = true }
8+
my-package = { version = "0.1.0", optional = true }
109

1110
[features]
12-
my-package1 = ["dep:my-package1"]
13-
my-package2 = ["dep:my-package2"]
11+
my-package = ["dep:my-package"]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Updating `dummy-registry` index
2-
Adding my-package1 v99999.0.0 to optional dependencies.
3-
Adding my-package2 v0.4.1 to optional dependencies.
2+
Adding my-package v0.1.0 to optional dependencies.

tests/testsuite/cargo_add/overwrite_no_optional/in/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = "99999.0.0"
9-
my-package2 = "0.4.1"
8+
my-package = "0.1.0"

tests/testsuite/cargo_add/overwrite_no_optional/mod.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,15 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
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-
}
10+
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
2311

2412
let project = Project::from_template(curr_dir!().join("in"));
2513
let project_root = project.root();
2614
let cwd = &project_root;
2715

2816
snapbox::cmd::Command::cargo_ui()
2917
.arg("add")
30-
.arg_line("my-package1 [email protected] --no-optional")
18+
.arg_line("my-package --no-optional")
3119
.current_dir(cwd)
3220
.assert()
3321
.success()

tests/testsuite/cargo_add/overwrite_no_optional/out/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = "99999.0.0"
9-
my-package2 = "0.4.1"
8+
my-package = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Updating `dummy-registry` index
2-
Adding my-package1 v99999.0.0 to dependencies.
3-
Adding my-package2 v0.4.1 to dependencies.
2+
Adding my-package v0.1.0 to dependencies.

tests/testsuite/cargo_add/overwrite_no_optional_with_optional/in/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = { version = "99999.0.0", optional = false }
9-
my-package2 = { version = "0.4.1", optional = false }
8+
my-package = { version = "0.1.0", optional = false }

tests/testsuite/cargo_add/overwrite_no_optional_with_optional/mod.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,15 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
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-
}
10+
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
2311

2412
let project = Project::from_template(curr_dir!().join("in"));
2513
let project_root = project.root();
2614
let cwd = &project_root;
2715

2816
snapbox::cmd::Command::cargo_ui()
2917
.arg("add")
30-
.arg_line("my-package1 [email protected] --optional")
18+
.arg_line("my-package --optional")
3119
.current_dir(cwd)
3220
.assert()
3321
.success()

tests/testsuite/cargo_add/overwrite_no_optional_with_optional/out/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = { version = "99999.0.0", optional = true }
9-
my-package2 = { version = "0.4.1", optional = true }
8+
my-package = { version = "0.1.0", optional = true }
109

1110
[features]
12-
my-package1 = ["dep:my-package1"]
13-
my-package2 = ["dep:my-package2"]
11+
my-package = ["dep:my-package"]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Updating `dummy-registry` index
2-
Adding my-package1 v99999.0.0 to optional dependencies.
3-
Adding my-package2 v0.4.1 to optional dependencies.
2+
Adding my-package v0.1.0 to optional dependencies.

tests/testsuite/cargo_add/overwrite_optional/in/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = "99999.0.0"
9-
my-package2 = "0.4.1"
8+
my-package = "0.1.0"

tests/testsuite/cargo_add/overwrite_optional/mod.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,15 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
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-
}
10+
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
2311

2412
let project = Project::from_template(curr_dir!().join("in"));
2513
let project_root = project.root();
2614
let cwd = &project_root;
2715

2816
snapbox::cmd::Command::cargo_ui()
2917
.arg("add")
30-
.arg_line("my-package1 [email protected] --optional")
18+
.arg_line("my-package --optional")
3119
.current_dir(cwd)
3220
.assert()
3321
.success()

tests/testsuite/cargo_add/overwrite_optional/out/Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ name = "cargo-list-test-fixture"
55
version = "0.0.0"
66

77
[dependencies]
8-
my-package1 = { version = "99999.0.0", optional = true }
9-
my-package2 = { version = "0.4.1", optional = true }
8+
my-package = { version = "0.1.0", optional = true }
109

1110
[features]
12-
my-package1 = ["dep:my-package1"]
13-
my-package2 = ["dep:my-package2"]
11+
my-package = ["dep:my-package"]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Updating `dummy-registry` index
2-
Adding my-package1 v99999.0.0 to optional dependencies.
3-
Adding my-package2 v0.4.1 to optional dependencies.
2+
Adding my-package v0.1.0 to optional dependencies.

tests/testsuite/cargo_add/overwrite_optional_with_no_optional/in/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ other = ["your-face/nose"]
1010

1111
[dependencies]
1212
your-face = { version = "99999.0.0", optional = true }
13-
my-package2 = { version = "0.4.1", optional = true }

tests/testsuite/cargo_add/overwrite_optional_with_no_optional/mod.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
cargo_test_support::registry::init();
10-
for ver in [
11-
"0.1.1+my-package",
12-
"0.2.0+my-package",
13-
"0.2.3+my-package",
14-
"0.4.1+my-package",
15-
"20.0.0+my-package",
16-
"99999.0.0+my-package",
17-
"99999.0.0-alpha.1+my-package",
18-
] {
19-
cargo_test_support::registry::Package::new("my-package2", ver).publish();
20-
}
10+
2111
cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package")
2212
.feature("nose", &[])
2313
.feature("mouth", &[])
@@ -31,7 +21,7 @@ fn case() {
3121

3222
snapbox::cmd::Command::cargo_ui()
3323
.arg("add")
34-
.arg_line("your-face [email protected] --no-optional")
24+
.arg_line("your-face --no-optional")
3525
.current_dir(cwd)
3626
.assert()
3727
.success()

tests/testsuite/cargo_add/overwrite_optional_with_no_optional/out/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ other = ["your-face/nose"]
1010

1111
[dependencies]
1212
your-face = { version = "99999.0.0" }
13-
my-package2 = { version = "0.4.1" }

tests/testsuite/cargo_add/overwrite_optional_with_no_optional/stderr.log

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
- eyes
66
- mouth
77
- nose
8-
Adding my-package2 v0.4.1 to dependencies.

tests/testsuite/cargo_add/overwrite_optional_with_optional/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@ use cargo_test_support::curr_dir;
77
#[cargo_test]
88
fn case() {
99
cargo_test_support::registry::init();
10-
for ver in [
11-
"0.1.1+my-package",
12-
"0.2.0+my-package",
13-
"0.2.3+my-package",
14-
"0.4.1+my-package",
15-
"20.0.0+my-package",
16-
"99999.0.0+my-package",
17-
"99999.0.0-alpha.1+my-package",
18-
] {
19-
cargo_test_support::registry::Package::new("my-package1", ver).publish();
20-
}
10+
cargo_test_support::registry::Package::new("my-package1", "99999.0.0").publish();
2111

2212
let project = Project::from_template(curr_dir!().join("in"));
2313
let project_root = project.root();
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Updating `dummy-registry` index
22
Adding my-package1 v99999.0.0 to optional dependencies.
3-
Adding my-package2 v0.4.1 to optional dependencies.

0 commit comments

Comments
 (0)