Work around intermittent test_complete failure

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
This commit is contained in:
Johannes Altmanninger
2026-01-26 17:05:25 +11:00
parent 3bd6771ae7
commit f2bb5b5d7f

View File

@@ -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 ");