From 152b676597821063f1ae7c8860fef5d2a1e1aa32 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sun, 5 Apr 2026 10:50:29 -0700 Subject: [PATCH] Fix flaky test relating to metadata remote URL (#16823) This test was flaking on Windows. Problem: The Windows CI test for turn metadata compared git remote URLs byte-for-byte even though equivalent remotes can be formatted differently across Git code paths. Solution: Normalize the expected and actual origin URLs in the test by trimming whitespace, removing a trailing slash, and stripping a trailing .git suffix before comparing. --- codex-rs/core/tests/responses_headers.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/codex-rs/core/tests/responses_headers.rs b/codex-rs/core/tests/responses_headers.rs index b4a200570..7a6e73ed0 100644 --- a/codex-rs/core/tests/responses_headers.rs +++ b/codex-rs/core/tests/responses_headers.rs @@ -23,6 +23,14 @@ use pretty_assertions::assert_eq; use tempfile::TempDir; use wiremock::matchers::header; +fn normalize_git_remote_url(url: &str) -> String { + let normalized = url.trim().trim_end_matches('/'); + normalized + .strip_suffix(".git") + .unwrap_or(normalized) + .to_string() +} + #[tokio::test] async fn responses_stream_includes_subagent_header_on_review() { core_test_support::skip_if_no_network!(); @@ -540,13 +548,15 @@ async fn responses_stream_includes_turn_metadata_header_for_git_workspace_e2e() .and_then(serde_json::Value::as_str), Some(expected_head.as_str()) ); + let actual_origin = workspace + .get("associated_remote_urls") + .and_then(serde_json::Value::as_object) + .and_then(|remotes| remotes.get("origin")) + .and_then(serde_json::Value::as_str) + .expect("origin remote should be present"); assert_eq!( - workspace - .get("associated_remote_urls") - .and_then(serde_json::Value::as_object) - .and_then(|remotes| remotes.get("origin")) - .and_then(serde_json::Value::as_str), - Some(expected_origin.as_str()) + normalize_git_remote_url(actual_origin), + normalize_git_remote_url(&expected_origin) ); assert_eq!( workspace