Repository navigation
Make bump_mtime monotonic so same-tick rewrites never share a stat key - #2968
Conversation
|
ESPHome Bot (@esphbot) review |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🟢 Approval recommended
The localized test-helper change prevents repeated timestamp collisions while preserving existing caller behavior.
No open issues 🎉
What changed in this PR
Updates the shared bump_mtime test helper to prevent timestamp collisions during same-tick rewrites, addressing the Windows test flake observed in #2962 without changing production code.
Changes:
- Tracks the last bumped modification time per path.
- Advances each timestamp beyond both the current file timestamp and its previous bump.
- Updates the helper’s docstring to describe the monotonic behavior.
| File | Description |
|---|---|
tests/conftest.py |
Makes repeated timestamp bumps strictly increasing per path. |
Review effort: Balanced
PR Review — Make bump_mtime monotonic so same-tick rewrites never share a stat keyCorrect, minimal fix for the Windows same-tick flake. Ready to merge. What works:
Notes (no action needed):
Checklist
Automated review by Kōan (Claude) |
ESPHome Bot (esphbot)
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2968 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 300 300
Lines 26429 26429
=======================================
Hits 26367 26367
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
What does this implement/fix?
Makes the test helper
bump_mtimemonotonic per file so two rewrites of the same file inside one filesystem clock tick never end up with the same(mtime, size)stat key. Fixes the flakytest_digest_moves_only_on_content_in_playfailure onwindows-latest.secrets.yamltwice with the same byte length (abc->abz) and bumps after each; when both writes land in the same Windows clock tick, both bumps compute the same mtime, the secrets cache sees an unchanged stat key and serves the stale parse, androtated != baselinefails.Verification
Replayed the failing sequence with every rewrite pinned to one mtime (what a same-tick write looks like): the old helper reports the fingerprint unchanged after the
abzrotation, the new one reports it moved.tests/test_device_yaml.py,tests/test_device_scanner_branches.pyandtests/test_mqtt_coordinator_extract.py(the files using the helper) pass locally, 439 tests.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
ruff,codespell, yaml/json/python checks).tests/where applicable.components.index.json/definitions/components/*.jsonhave not been hand-edited (regenerate viascript/sync_components.pyif a sync is needed).docs/ARCHITECTURE.mdand/ordocs/API.md.