mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(doctor): exit nonzero on failed checks
This commit is contained in:
@@ -104,6 +104,12 @@ pub fn run(output: Output) -> Result<Vec<CheckResult>> {
|
||||
Ok(checks)
|
||||
}
|
||||
|
||||
/// Whether the rendered doctor report contains an active failure.
|
||||
/// `NotApplicable` remains informational and must not change the exit code.
|
||||
pub fn has_failures(checks: &[CheckResult]) -> bool {
|
||||
checks.iter().any(|check| check.status == CheckStatus::Fail)
|
||||
}
|
||||
|
||||
/// Ensure the daemon is reachable and give the browser extension time to
|
||||
/// connect before checks run. Returns a single [`DaemonState`] snapshot
|
||||
/// for check evaluation.
|
||||
@@ -500,6 +506,21 @@ mod m2_tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_active_failures_make_doctor_unsuccessful() {
|
||||
let healthy = vec![
|
||||
CheckResult::ok("ok", "ready"),
|
||||
CheckResult::na("optional", "not connected"),
|
||||
];
|
||||
assert!(!has_failures(&healthy));
|
||||
|
||||
let unhealthy = vec![
|
||||
CheckResult::ok("ok", "ready"),
|
||||
CheckResult::fail("broken", "not ready", "repair it"),
|
||||
];
|
||||
assert!(has_failures(&unhealthy));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn browsers_check_reports_na_when_no_browser_connected() {
|
||||
// Review M2: 0 browsers means there is nothing to compare
|
||||
|
||||
Reference in New Issue
Block a user