Allow '.' in workspace.default-members in non-virtual workspaces.

This commit is contained in:
Ted Kaminski 2022-06-23 16:46:35 +00:00
parent 92ff479275
commit 380be40922
2 changed files with 32 additions and 1 deletions

View File

@ -690,7 +690,9 @@ impl<'cfg> Workspace<'cfg> {
for path in default {
let normalized_path = paths::normalize_path(&path);
let manifest_path = normalized_path.join("Cargo.toml");
if !self.members.contains(&manifest_path) {
if !self.members.contains(&manifest_path)
&& (self.is_virtual() || manifest_path != root_manifest_path)
{
// default-members are allowed to be excluded, but they
// still must be referred to by the original (unfiltered)
// members list. Note that we aren't testing against the

View File

@ -119,6 +119,35 @@ fn non_virtual_default_members_build_other_member() {
.run();
}
#[cargo_test]
fn non_virtual_default_members_build_root_project() {
let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.1.0"
authors = []
[workspace]
members = ["bar"]
default-members = ["."]
"#,
)
.file("src/main.rs", "fn main() {}")
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
.file("bar/src/lib.rs", "pub fn bar() {}")
.build();
p.cargo("build")
.with_stderr(
"[..] Compiling foo v0.1.0 ([..])\n\
[..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n",
)
.run();
}
#[cargo_test]
fn inferred_root() {
let p = project()