test(agent): stop cli probe tests racing process startup
The hung-CLI probe tests gave the deadline 200ms, which a cold exec of a just-written temp executable can exceed before it prints — the capture came back empty and the auth-marker assert flaked (2 of 3 isolated runs). Give the probes a 2s budget, well past spawn cost, so the timeout branch is reached with the script's output already drained.
This commit is contained in:
parent
685c5dd17e
commit
4702c8e06a
|
|
@ -132,6 +132,12 @@ fn verified_catalogs_reject_empty_auth_and_unknown_output() {
|
|||
// contract, exercised in `cli_probe_support`'s own test module
|
||||
// (`bounded_cli_output_drains_large_stdout_and_stderr_before_exit`).
|
||||
|
||||
/// Probe budget for the hung-CLI tests. Generous relative to spawning a
|
||||
/// fake CLI (milliseconds) so the timeout branch is reached with the
|
||||
/// script's output already captured, which is what these tests assert on.
|
||||
#[cfg(unix)]
|
||||
const PROBE_BUDGET: Duration = Duration::from_secs(2);
|
||||
|
||||
/// Writes an executable `/bin/sh` script standing in for a real CLI so
|
||||
/// `*_models_from_exe` can be pointed at it directly — the discover
|
||||
/// chain's fixed `&["models"]` args rule out the `/bin/sh -c <script>`
|
||||
|
|
@ -164,7 +170,10 @@ fn antigravity_query_surfaces_auth_prompt_when_it_hangs_mid_oauth() {
|
|||
"agy-hang",
|
||||
"printf 'Authentication required. Please visit the URL to log in:\\n'; sleep 5",
|
||||
);
|
||||
let message = antigravity_models_from_exe(&exe, Duration::from_millis(200)).unwrap_err();
|
||||
// The budget must outlast spawning a just-written temp executable, not
|
||||
// just the probe's own polling: a 200ms window let a cold exec reach the
|
||||
// deadline before `printf` ran, so the assert flaked on an empty capture.
|
||||
let message = antigravity_models_from_exe(&exe, PROBE_BUDGET).unwrap_err();
|
||||
assert_eq!(
|
||||
message,
|
||||
"Antigravity is not authenticated. Run `agy` once in a terminal."
|
||||
|
|
@ -178,8 +187,8 @@ fn grok_query_falls_back_to_truncated_tail_when_timeout_has_no_auth_marker() {
|
|||
"grok-hang",
|
||||
"printf 'initializing sandbox...\\nstill working\\n'; sleep 5",
|
||||
);
|
||||
let message = grok_models_from_exe(&exe, Duration::from_millis(200)).unwrap_err();
|
||||
assert!(message.contains("Grok Build CLI timed out after 0s"));
|
||||
let message = grok_models_from_exe(&exe, PROBE_BUDGET).unwrap_err();
|
||||
assert!(message.contains("Grok Build CLI timed out after 2s"));
|
||||
assert!(message.contains("`grok`"));
|
||||
assert!(message.contains("still working"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,6 +176,13 @@ pub(crate) fn tail_snippet(stdout: &str, stderr: &str) -> String {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Probe budget for the hung-CLI tests. Generous relative to spawning a
|
||||
/// shell (milliseconds) so the deadline is reached with the script's
|
||||
/// output already captured, which is what these tests assert on — a
|
||||
/// tighter window races process startup on a loaded machine.
|
||||
#[cfg(unix)]
|
||||
const PROBE_BUDGET: Duration = Duration::from_secs(2);
|
||||
|
||||
#[test]
|
||||
fn tail_snippet_truncates_to_last_n_chars() {
|
||||
let long = "a".repeat(500);
|
||||
|
|
@ -260,7 +267,7 @@ mod tests {
|
|||
CliName::Antigravity,
|
||||
Path::new("/bin/sh"),
|
||||
&["-c", script],
|
||||
Duration::from_millis(200),
|
||||
PROBE_BUDGET,
|
||||
) {
|
||||
BoundedProbe::TimedOut { stdout, .. } => {
|
||||
assert!(String::from_utf8_lossy(&stdout).contains("Authentication required"));
|
||||
|
|
@ -325,7 +332,7 @@ mod tests {
|
|||
// must now name the fix.
|
||||
let script =
|
||||
"printf 'Authentication required. Please visit the URL to log in:\\n'; sleep 5";
|
||||
let probe_timeout = Duration::from_millis(200);
|
||||
let probe_timeout = PROBE_BUDGET;
|
||||
let probe = bounded_cli_output(
|
||||
CliName::Antigravity,
|
||||
Path::new("/bin/sh"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue