diff --git a/benchmarks/aft-search/slice-descriptors/fix-ort-exit-test-windows-path.json b/benchmarks/aft-search/slice-descriptors/fix-ort-exit-test-windows-path.json new file mode 100644 index 0000000000..d57ff708b9 --- /dev/null +++ b/benchmarks/aft-search/slice-descriptors/fix-ort-exit-test-windows-path.json @@ -0,0 +1,12 @@ +{ + "slice_class": "non_ranking", + "targeted_mechanism": "none", + "kind": "harness", + "fixtures": [ + "harness-goldens" + ], + "slices": [ + "fix-ort-exit-test-windows-path" + ], + "note": "Test-only: the CLI exit test keeps PATH (and SystemRoot on Windows) in the child's cleared environment so AFT can find git on Windows, and an early exit now prints aft's stderr. No product code changes." +} diff --git a/crates/aft/tests/integration/cli_ort_exit_test.rs b/crates/aft/tests/integration/cli_ort_exit_test.rs index e5c840b26f..e26974607f 100644 --- a/crates/aft/tests/integration/cli_ort_exit_test.rs +++ b/crates/aft/tests/integration/cli_ort_exit_test.rs @@ -11,11 +11,14 @@ use std::time::{Duration, Instant}; use crate::test_helpers::aft_binary; -fn wait_for_file(path: &Path, child: &mut Child, what: &str) { +fn wait_for_file(path: &Path, child: &mut Child, lines: &mpsc::Receiver, what: &str) { let deadline = Instant::now() + Duration::from_secs(60); while !path.exists() { if let Some(status) = child.try_wait().unwrap() { - panic!("aft exited with {status} before {what}"); + // Give the reader a moment to pass on the last lines aft wrote. + std::thread::sleep(Duration::from_millis(200)); + let stderr: Vec = lines.try_iter().collect(); + panic!("aft exited with {status} before {what}; stderr: {stderr:#?}"); } assert!(Instant::now() < deadline, "timed out waiting for {what}"); std::thread::sleep(Duration::from_millis(10)); @@ -46,6 +49,12 @@ fn warmup_exit_waits_for_a_fill_inside_model_creation() { .arg(&root) .args(["--only", "semantic", "--timeout", "2000"]) .env_clear() + // Keep the search path, and on Windows the system folder: AFT needs + // git to decide whether the root is a repository, and on Windows it + // cannot find git, or run it, without them. The meaning-search fill + // then never starts and the test never reaches the exit it checks. + .env("PATH", std::env::var_os("PATH").unwrap_or_default()) + .envs(std::env::var_os("SystemRoot").map(|value| ("SystemRoot", value))) .env("HOME", &home) .env("USERPROFILE", &home) .env("APPDATA", &home) @@ -73,6 +82,7 @@ fn warmup_exit_waits_for_a_fill_inside_model_creation() { wait_for_file( &hold.join("entered"), &mut child, + &lines_rx, "the fill entered model creation", );