Skip to content

Commit 01bb465

Browse files
jpnurmiclaude
andcommitted
Fix flaky test_native_cache_keep by polling for cache file
Replace fixed 2s sleep with wait_for_file polling (up to 10s) for the cache_keep=True case. On slow CI machines the daemon may not finish writing the cache file within 2 seconds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d433459 commit 01bb465

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/assertions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,12 @@ def assert_failed_proxy_auth_request(stdout):
559559

560560

561561
def wait_for_file(path, timeout=10.0, poll_interval=0.1):
562+
import glob
562563
import time
563564

564565
deadline = time.time() + timeout
565566
while time.time() < deadline:
566-
if path.exists():
567+
if glob.glob(str(path)):
567568
return True
568569
time.sleep(poll_interval)
569570
return False

tests/test_integration_native.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .assertions import (
2020
assert_meta,
2121
assert_session,
22+
wait_for_file,
2223
)
2324
from .conditions import has_native, is_kcov, is_asan
2425

@@ -644,11 +645,9 @@ def test_native_cache_keep(cmake, cache_keep):
644645
env=env,
645646
)
646647

647-
# Wait for crash to be processed
648-
time.sleep(2)
649-
650-
cache_files = list(cache_dir.glob("*.envelope"))
651648
if cache_keep:
652-
assert len(cache_files) == 1
649+
assert wait_for_file(cache_dir / "*.envelope")
650+
assert len(list(cache_dir.glob("*.envelope"))) == 1
653651
else:
654-
assert len(cache_files) == 0
652+
time.sleep(2)
653+
assert len(list(cache_dir.glob("*.envelope"))) == 0

0 commit comments

Comments
 (0)