Skip to content

fix(tests): make dotnet TRX tests deterministic via explicit mtimes - #4040

Closed
AngelVRodC wants to merge 1 commit into
rtk-ai:developfrom
AngelVRodC:fix/dotnet-trx-flaky-mtime
Closed

AngelVRodC wants to merge 1 commit into
rtk-ai:developfrom
AngelVRodC:fix/dotnet-trx-flaky-mtime

Conversation

@AngelVRodC

Copy link
Copy Markdown
Contributor

Fixes #4037

Summary

  • Replace wall-clock-dependent fixture mtimes in three flaky dotnet tests with explicit File::set_modified timestamps (old = base − 1 day, new = base + 1 hour), deriving every since cutoff from the same base so results are independent of filesystem mtime granularity (HFS+/FAT 1–2s flooring).
  • Remove all thread::sleep synchronization from these tests; add a tiny #[cfg(test)] write_trx_with_mtime helper in src/cmds/dotnet/mod.rs (inline module — automod::dir! would declare a new file as a production module).
  • Fixes the reported flake in test_parse_trx_files_in_dir_since_ignores_older_files plus two sibling latent flakes found during investigation (test_find_recent_trx_in_dir_picks_newest_trx, test_merge_test_summary_from_trx_ignores_stale_fallback_file).

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test — 0 warnings, 3781 passed / 0 failed
  • Repeated the dotnet TRX test suites 20× consecutively — 0 flakes, and the suites no longer sleep (each run finishes in ~0.02s)
  • Test-only diff: 3 files in src/cmds/dotnet/, +37/−16; no production code, no new dependencies

Replace thread::sleep-based wall-clock separation in the three flaky
dotnet TRX tests with explicit file mtimes set via File::set_modified
(stable since Rust 1.75). Sleep margins of 5-10ms fall inside the 1-2s
mtime granularity of HFS+/FAT/CI mounts, causing nondeterministic
failures. Timestamps are now pinned (old = base - 1 day, new =
base + 1 hour) and since-cutoffs derive from the same base value, so
outcomes never depend on elapsed real time.

Fixes rtk-ai#4037
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes flaky dotnet TRX tests by replacing wall-clock-dependent mtimes and thread::sleep synchronization with explicit File::set_modified timestamps derived from a shared base time. A new #[cfg(test)] helper write_trx_with_mtime is added to pin fixture mtimes precisely, eliminating filesystem mtime granularity issues.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4037


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh

KuSh commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix and for finding the two sibling flakes. Issue #4037 was closed by #4048 (merged 2026-09-17), which covers the same three tests: old fixtures are pinned ten seconds before the cutoff and new ones ten seconds after through an explicit set_modified, and the sleeps are gone, so the dotnet TRX suites no longer depend on filesystem mtime granularity. The shared write_trx_with_mtime helper here is the one thing develop does not have, and with a per module set_mtime helper already in place that did not look like a reason to keep this open. Please comment or reopen if you think a part of this was missed.

@KuSh KuSh closed this Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: dotnet_trx test_parse_trx_files_in_dir_since_ignores_older_files depends on file mtimes

2 participants