From 6070b0aab40cf475400eaad4fe388606608793d3 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 13 Jul 2022 21:10:22 -0500 Subject: [PATCH] Add a test to check for regressions in selecting the correct workspace when there are nested workspaces --- tests/testsuite/workspaces.rs | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index d58b0220a21..ee41b35bd5a 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2454,3 +2454,50 @@ fn virtual_primary_package_env_var() { p.cargo("clean").run(); p.cargo("test -p foo").run(); } + +#[cargo_test] +fn ensure_correct_workspace_when_nested() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + + [project] + name = "bar" + version = "0.1.0" + authors = [] + "#, + ) + .file("src/lib.rs", "") + .file( + "sub/Cargo.toml", + r#" + [workspace] + members = ["foo"] + "#, + ) + .file( + "sub/foo/Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "../.."} + "#, + ) + .file("sub/foo/src/main.rs", "fn main() {}"); + let p = p.build(); + p.cargo("tree") + .cwd("sub/foo") + .with_stdout( + "\ +foo v0.1.0 ([..]/foo/sub/foo) +└── bar v0.1.0 ([..]/foo)\ + ", + ) + .run(); +}