Skip to content

Commit

Permalink
Add detect_workspace_inherit_public test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
linyihai committed Dec 1, 2023
1 parent a6ca281 commit 48c998f
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = ["primary", "dependency"]

[workspace.dependencies]
foo = { version = "0.0.0", path = "./dependency"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "foo"
version = "0.0.0"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cargo-features = ["public-dependency"]
[package]
name = "bar"
version = "0.0.0"
Empty file.
26 changes: 26 additions & 0 deletions tests/testsuite/cargo_add/detect_workspace_inherit_public/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;

#[cargo_test]
fn case() {
cargo_test_support::registry::init();

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")
.args(["foo", "-p", "bar", "--public"])
.masquerade_as_nightly_cargo(&["public-dependency"])
.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,5 @@
[workspace]
members = ["primary", "dependency"]

[workspace.dependencies]
foo = { version = "0.0.0", path = "./dependency"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[package]
name = "foo"
version = "0.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cargo-features = ["public-dependency"]
[package]
name = "bar"
version = "0.0.0"

[dependencies]
foo = { workspace = true, public = true }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adding foo (workspace) to public dependencies.
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod deprecated_section;
mod detect_workspace_inherit;
mod detect_workspace_inherit_features;
mod detect_workspace_inherit_optional;
mod detect_workspace_inherit_public;
mod dev;
mod dev_build_conflict;
mod dev_prefer_existing_version;
Expand Down

0 comments on commit 48c998f

Please sign in to comment.