From f2bb5b5d7f86a14ed1e92cfdb309205c63f5cc9c Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 26 Jan 2026 17:05:25 +1100 Subject: [PATCH] Work around intermittent test_complete failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_complete and test_history_races both have the #[serial] annotations. Still, "cargo test" sometimes fails with thread 'complete::tests::test_complete' (370134) panicked at │ src/complete.rs:2814:13: │ assertion `left == right` failed │ left: [("TTestWithColon", false), ("history-races-test-balloon", │ true), ("test/", true)] │ right: [("TTestWithColon", false), ("test/", true)] │ I don't understand why this happens (filesystem race condition?) but let's fix it by having "test_complete" ignore files from other tests. Fixes #12184 --- src/complete.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/complete.rs b/src/complete.rs index 5d8c9250e..8a4a4e3a5 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -2736,6 +2736,8 @@ fn test_complete() { { std::fs::write(r"test/complete_test/gnarlybracket\[abc]", []).unwrap(); std::fs::write(r"test/complete_test/colon:TTestWithColon", []).unwrap(); + std::fs::create_dir_all("test/complete_test/cwd-for-colon").unwrap(); + std::fs::write(r"test/complete_test/cwd-for-colon/test-file-in-cwd", []).unwrap(); } std::fs::write(r"test/complete_test/equal=abc", []).unwrap(); // On MSYS, the executable bit cannot be set manually, is set automatically @@ -2812,26 +2814,28 @@ macro_rules! whole_token_completion_dominates { }; } + parser.pushd("test/complete_test/cwd-for-colon"); whole_token_completion_dominates!( - ": test/complete_test/colon:", + ": ../colon:", CompletionRequestOptions::default(), "TTestWithColon", - "test/", + "test-file-in-cwd", ); // Even when it has a case mismatch. whole_token_completion_dominates!( - ": test/complete_test/colon:t", + ": ../colon:t", CompletionRequestOptions::default(), - "test/complete_test/colon:TTestWithColon", - "est/", + "../colon:TTestWithColon", + "est-file-in-cwd", ); // Even when it is not a prefix. whole_token_completion_dominates!( - ": test/complete_test/colon:Tes", + ": ../colon:Tes", fuzzy_options, - "test/complete_test/colon:TTestWithColon", - "test/complete_test/colon:test/", + "../colon:TTestWithColon", + "../colon:test-file-in-cwd", ); + parser.popd(); } macro_rules! unique_completion_applies_as { @@ -2893,17 +2897,19 @@ macro_rules! unique_completion_applies_as { #[cfg(not(cygwin))] // Colons are not legal filename characters on WIN32/CYGWIN { + parser.pushd("test/complete_test/cwd-for-colon"); unique_completion_applies_as!( - r"touch test/complete_test/colon", + r"touch ../colon", r":TTestWithColon", - r"touch test/complete_test/colon:TTestWithColon ", + r"touch ../colon:TTestWithColon ", ); unique_completion_applies_as!( - r#"touch "test/complete_test/colon:"#, + r#"touch "../colon:"#, r"TTestWithColon", - r#"touch "test/complete_test/colon:TTestWithColon" "#, + r#"touch "../colon:TTestWithColon" "#, ); + parser.popd(); } unique_completion_applies_as!("echo $SOMEV", r"AR", "echo $SOMEVAR ");