From 78f4c0456f462d91c2ebabd83ea871fa020429e1 Mon Sep 17 00:00:00 2001 From: 0xPoe Date: Tue, 24 Feb 2026 08:53:25 +0100 Subject: [PATCH] test: add the workspace search error case Signed-off-by: 0xPoe fix Signed-off-by: 0xPoe --- tests/testsuite/workspaces.rs | 36 ++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 0f8ab785b..bbafc31eb 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -6,7 +6,10 @@ use std::fs; use crate::prelude::*; use cargo_test_support::registry::Package; use cargo_test_support::str; -use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project, sleep_ms}; +use cargo_test_support::{ + ProjectBuilder, basic_lib_manifest, basic_manifest, git, paths, project, project_in_home, + sleep_ms, +}; #[cargo_test] fn simple_explicit() { @@ -2198,6 +2201,37 @@ fn cargo_home_at_root_works() { p.cargo("check --frozen").env("CARGO_HOME", p.root()).run(); } +#[cargo_test] +fn parent_manifest_error_mentions_workspace_search() { + ProjectBuilder::new(paths::home()) + .file( + "Cargo.toml", + r#" + [package] + name = "home-manifest" + version = "0.1.0" + authors = [] + "#, + ) + .build(); + + let p = project_in_home("stuff") + .file("src/main.rs", "fn main() {}") + .build(); + + p.cargo("check") + .with_status(101) + .with_stderr_data(str![[r#" +[ERROR] failed to parse manifest at `[ROOT]/home/Cargo.toml` + +Caused by: + no targets specified in the manifest + either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present + +"#]]) + .run(); +} + #[cargo_test] fn relative_rustc() { let p = project()