Skip to content

Commit b3d4262

Browse files
committed
fix: align bench/build diagnostic assertions with actionable contract (#7975)
Several library tests asserted obsolete diagnostic wording and blocked the Rust test gate, even though the exercised behavior already returns the intended, more actionable diagnostics. - Duplicate bench scenario tests expected the old validate.rs phrasing ("duplicate bench scenario id `x`" / "workload paths relative to the bench root") and `details.id == "<scenario>"`. The current `resolve_duplicate_scenario_ids` path emits the structured `duplicate_scenario_id` diagnostic naming both discovered source paths with `--path` / `--rig` remediation, and carries the diagnostic code in `details.id`. Assertions now validate that contract (covers the two listed tests plus selected_parse_still_rejects_selected_duplicate..., which had the same stale wording). - resolve_build_command_guides_unconfigured_components and extension_guidance_hints_point_to_supported_paths both expect a `scripts.build` component-owned-command hint that the guidance helper no longer emitted. Restore the `scripts.<capability>` hint so the unconfigured-component diagnostic actually points at the escape hatch both tests document. All bench parsing (45), extension (29), and the named build tests pass.
1 parent 07653f7 commit b3d4262

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

src/core/extension/bench/parsing/mod.rs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,17 +1379,33 @@ mod tests {
13791379
.and_then(|v| v.as_str())
13801380
.unwrap_or("");
13811381

1382+
// The duplicate is surfaced by `resolve_duplicate_scenario_ids`, which
1383+
// emits the structured `duplicate_scenario_id` diagnostic naming the
1384+
// conflicting id, both discovered source paths, and the actionable
1385+
// `--path` / `--rig` remediation.
13821386
assert!(
1383-
problem.contains("duplicate bench scenario id `heavy`"),
1387+
problem.contains("duplicate bench scenario id(s) discovered"),
13841388
"expected duplicate-id problem, got: {}",
13851389
problem
13861390
);
1391+
assert!(
1392+
problem.contains("`heavy`"),
1393+
"problem should name the id: {problem}"
1394+
);
13871395
assert!(problem.contains("tests/bench/reads/heavy.php"));
13881396
assert!(problem.contains("tests/bench/writes/heavy.php"));
1389-
assert!(problem.contains("workload paths relative to the bench root"));
1397+
assert!(
1398+
problem.contains("homeboy bench --path <workspace>"),
1399+
"problem should offer the --path remediation: {problem}"
1400+
);
1401+
assert!(
1402+
problem.contains("--rig <id>"),
1403+
"problem should offer the --rig remediation: {problem}"
1404+
);
1405+
// `id` carries the diagnostic code, not the scenario id.
13901406
assert_eq!(
13911407
err.details.get("id").and_then(|v| v.as_str()),
1392-
Some("heavy")
1408+
Some("duplicate_scenario_id")
13931409
);
13941410
}
13951411

@@ -1459,7 +1475,14 @@ mod tests {
14591475
.and_then(|v| v.as_str())
14601476
.unwrap_or("");
14611477

1462-
assert!(problem.contains("duplicate bench scenario id `target`"));
1478+
assert!(
1479+
problem.contains("duplicate bench scenario id(s) discovered"),
1480+
"expected duplicate-id problem, got: {problem}"
1481+
);
1482+
assert!(
1483+
problem.contains("`target`"),
1484+
"problem should name the id: {problem}"
1485+
);
14631486
}
14641487

14651488
#[test]

src/core/extension/capability.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,23 @@ pub(crate) fn extension_guidance_hints(
232232
),
233233
};
234234

235+
// Point at the component-owned escape hatch too: a component can supply its
236+
// own command via a `scripts.<capability>` entry without linking an
237+
// extension at all. Named after the capability so the hint is actionable
238+
// (e.g. `scripts.build`) and independently regression-covered.
239+
let scripts_hint = match capability {
240+
Some(capability) => format!(
241+
"Use `scripts.{}` for component-owned {} commands (no extension required): set it in the component config.",
242+
capability.label().to_lowercase(),
243+
capability.label().to_lowercase()
244+
),
245+
None => "Use `scripts.<command>` for component-owned commands (no extension required): set it in the component config."
246+
.to_string(),
247+
};
248+
235249
vec![
236250
link_hint,
251+
scripts_hint,
237252
"List installed extensions: homeboy extension list".to_string(),
238253
format!(
239254
"Component config lives at ~/.config/homeboy/components/{}.json or in a portable homeboy.json discovered from the component path.",

0 commit comments

Comments
 (0)