Skip to content

Stop DateTimeDiff message tests from racing the clock - #1833

Merged
alganet merged 1 commit into
mainfrom
fix/datetimediff-test-flakiness
Aug 16, 2026
Merged

Stop DateTimeDiff message tests from racing the clock#1833
alganet merged 1 commit into
mainfrom
fix/datetimediff-test-flakiness

Conversation

@alganet

@alganet alganet commented Aug 16, 2026

Copy link
Copy Markdown
Member

The "Without adjacent result" tests validated "1 year ago" against positive() and between(2, 5), expecting both rules to fail so that AllOf reports "must pass all the rules".

DateTimeDiff reads the clock for $now and only then parses the input, so a relative input reads the clock a second time. When both reads land in the same microsecond the difference is exactly one year and the comparison value is 1 instead of 0, positive() passes, and AllOf reports "must pass the rules" instead. Running the file alone hides it; in the full suite, with caches warm, roughly half the runs failed.

Move the input a minute off the boundary so the number of years is always 0, the same idiom the documentation already uses. The underlying validator remains sensitive to inputs that fall exactly on a boundary.

The "Without adjacent result" tests validated "1 year ago" against
positive() and between(2, 5), expecting both rules to fail so that
AllOf reports "must pass all the rules".

DateTimeDiff reads the clock for $now and only then parses the input,
so a relative input reads the clock a second time. When both reads land
in the same microsecond the difference is exactly one year and the
comparison value is 1 instead of 0, positive() passes, and AllOf reports
"must pass the rules" instead. Running the file alone hides it; in the
full suite, with caches warm, roughly half the runs failed.

Move the input a minute off the boundary so the number of years is
always 0, the same idiom the documentation already uses. The underlying
validator remains sensitive to inputs that fall exactly on a boundary.
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.12%. Comparing base (56239ca) to head (c5a4c64).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1833   +/-   ##
=========================================
  Coverage     97.12%   97.12%           
  Complexity     1069     1069           
=========================================
  Files           198      198           
  Lines          2505     2505           
=========================================
  Hits           2433     2433           
  Misses           72       72           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alganet
alganet merged commit d2f78a0 into main Aug 16, 2026
10 checks passed
@alganet
alganet deleted the fix/datetimediff-test-flakiness branch August 16, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant