Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --public for cargo add #13046

Merged
merged 10 commits into from
Dec 1, 2023
17 changes: 2 additions & 15 deletions tests/testsuite/cargo_add/no_public/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
for name in ["my-package1", "my-package2"] {
for ver in [
"0.1.1+my-package",
"0.2.0+my-package",
"0.2.3+my-package",
"0.4.1+my-package",
"20.0.0+my-package",
"99999.0.0+my-package",
"99999.0.0-alpha.1+my-package",
] {
cargo_test_support::registry::Package::new(name, ver).publish();
}
}

cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("my-package1 my-package2@0.4.1 --no-public")
.arg_line("my-package@0.1.0 --no-public")
linyihai marked this conversation as resolved.
Show resolved Hide resolved
.current_dir(cwd)
.masquerade_as_nightly_cargo(&["public-dependency"])
.assert()
Expand Down
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/no_public/out/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = "99999.0.0"
my-package2 = "0.4.1"
my-package = "0.1.0"
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/no_public/stderr.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Updating `dummy-registry` index
Adding my-package1 v99999.0.0 to dependencies.
Adding my-package2 v0.4.1 to dependencies.
Adding my-package v0.1.0 to dependencies.
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/overwrite_no_public/in/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = "99999.0.0"
my-package2 = "0.4.1"
my-package = "0.1.0"
17 changes: 2 additions & 15 deletions tests/testsuite/cargo_add/overwrite_no_public/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
for name in ["my-package1", "my-package2"] {
for ver in [
"0.1.1+my-package",
"0.2.0+my-package",
"0.2.3+my-package",
"0.4.1+my-package",
"20.0.0+my-package",
"99999.0.0+my-package",
"99999.0.0-alpha.1+my-package",
] {
cargo_test_support::registry::Package::new(name, ver).publish();
}
}

cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("my-package1 my-package2@0.4.1 --no-public")
.arg_line("my-package@0.1.0 --no-public")
.current_dir(cwd)
.masquerade_as_nightly_cargo(&["public-dependency"])
.assert()
Expand Down
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/overwrite_no_public/out/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = "99999.0.0"
my-package2 = "0.4.1"
my-package = "0.1.0"
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/overwrite_no_public/stderr.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Updating `dummy-registry` index
Adding my-package1 v99999.0.0 to dependencies.
Adding my-package2 v0.4.1 to dependencies.
Adding my-package v0.1.0 to dependencies.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = { version = "99999.0.0", public = false }
my-package2 = { version = "0.4.1", public = false }
my-package = { version = "0.1.0", public = false }
17 changes: 2 additions & 15 deletions tests/testsuite/cargo_add/overwrite_no_public_with_public/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
for name in ["my-package1", "my-package2"] {
for ver in [
"0.1.1+my-package",
"0.2.0+my-package",
"0.2.3+my-package",
"0.4.1+my-package",
"20.0.0+my-package",
"99999.0.0+my-package",
"99999.0.0-alpha.1+my-package",
] {
cargo_test_support::registry::Package::new(name, ver).publish();
}
}

cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("my-package1 my-package2@0.4.1 --public")
.arg_line("my-package@0.1.0 --public")
.current_dir(cwd)
.masquerade_as_nightly_cargo(&["public-dependency"])
.assert()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = { version = "99999.0.0", public = true }
my-package2 = { version = "0.4.1", public = true }
my-package = { version = "0.1.0", public = true }
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Updating `dummy-registry` index
Adding my-package1 v99999.0.0 to public dependencies.
Adding my-package2 v0.4.1 to public dependencies.
Adding my-package v0.1.0 to public dependencies.
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/overwrite_public/in/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = "99999.0.0"
my-package2 = "0.4.1"
my-package = "0.1.0"
17 changes: 2 additions & 15 deletions tests/testsuite/cargo_add/overwrite_public/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
for name in ["my-package1", "my-package2"] {
for ver in [
"0.1.1+my-package",
"0.2.0+my-package",
"0.2.3+my-package",
"0.4.1+my-package",
"20.0.0+my-package",
"99999.0.0+my-package",
"99999.0.0-alpha.1+my-package",
] {
cargo_test_support::registry::Package::new(name, ver).publish();
}
}

cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("my-package1 my-package2@0.4.1 --public")
.arg_line("my-package --public")
.current_dir(cwd)
.masquerade_as_nightly_cargo(&["public-dependency"])
.assert()
Expand Down
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/overwrite_public/out/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = { version = "99999.0.0", public = true }
my-package2 = { version = "0.4.1", public = true }
my-package = { version = "0.1.0", public = true }
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/overwrite_public/stderr.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Updating `dummy-registry` index
Adding my-package1 v99999.0.0 to public dependencies.
Adding my-package2 v0.4.1 to public dependencies.
Adding my-package v0.1.0 to public dependencies.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = { version = "99999.0.0", public = true }
my-package2 = { version = "0.4.1", public = true }
my-package = { version = "0.1.0", public = true }
17 changes: 2 additions & 15 deletions tests/testsuite/cargo_add/overwrite_public_with_no_public/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
for name in ["my-package1", "my-package2"] {
for ver in [
"0.1.1+my-package",
"0.2.0+my-package",
"0.2.3+my-package",
"0.4.1+my-package",
"20.0.0+my-package",
"99999.0.0+my-package",
"99999.0.0-alpha.1+my-package",
] {
cargo_test_support::registry::Package::new(name, ver).publish();
}
}

cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("my-package1 my-package2@0.4.1 --no-public")
.arg_line("my-package --no-public")
.current_dir(cwd)
.masquerade_as_nightly_cargo(&["public-dependency"])
.assert()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = { version = "99999.0.0" }
my-package2 = { version = "0.4.1" }
my-package = { version = "0.1.0" }
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Updating `dummy-registry` index
Adding my-package1 v99999.0.0 to dependencies.
Adding my-package2 v0.4.1 to dependencies.
Adding my-package v0.1.0 to dependencies.
17 changes: 2 additions & 15 deletions tests/testsuite/cargo_add/public/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
cargo_test_support::registry::init();
for name in ["my-package1", "my-package2"] {
for ver in [
"0.1.1+my-package",
"0.2.0+my-package",
"0.2.3+my-package",
"0.4.1+my-package",
"20.0.0+my-package",
"99999.0.0+my-package",
"99999.0.0-alpha.1+my-package",
] {
cargo_test_support::registry::Package::new(name, ver).publish();
}
}

cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

snapbox::cmd::Command::cargo_ui()
.arg("add")
.arg_line("my-package1 my-package2@0.4.1 --public")
.arg_line("my-package@0.1.0 --public")
.current_dir(cwd)
.masquerade_as_nightly_cargo(&["public-dependency"])
.assert()
Expand Down
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/public/out/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ name = "cargo-list-test-fixture"
version = "0.0.0"

[dependencies]
my-package1 = { version = "99999.0.0", public = true }
my-package2 = { version = "0.4.1", public = true }
my-package = { version = "0.1.0", public = true }
3 changes: 1 addition & 2 deletions tests/testsuite/cargo_add/public/stderr.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Updating `dummy-registry` index
Adding my-package1 v99999.0.0 to public dependencies.
Adding my-package2 v0.4.1 to public dependencies.
Adding my-package v0.1.0 to public dependencies.