Repository navigation
test(watch): stop the watcher test clock from breaking subprocess waits - #5449
Deepjyoti-Sarmah wants to merge 2 commits into
Conversation
drive_watch replaces time.sleep for the whole process. A subprocess wait during the rebuild then runs the fake clock and aborts the rebuild. Force that wait.
Patching watch_mod.time.sleep patched the shared time module, so waiting for git in _git_head could raise KeyboardInterrupt before graph.json was written. The parallel CI runs hit this often; a loaded serial run hits it too.
|
Thanks for the pull request, @Deepjyoti-Sarmah. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
2 possible issues to check · Medium impact
2 possible issues we couldn't confirm
- Watch tests now swap the whole
timename in watch.py, so any othertimeattribute used there raises AttributeError under test ·tests/test_language_override_lifecycle.py:171 - The subprocess clock regression test checks only that the child finished and the graph updated, so it would not catch the clock reaching sub ·
tests/test_language_override_lifecycle.py:213
They don't change the score.
Code graph · 35 functions depend on this change
- 2 of 620 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 6824a1c · Full report in the Graphify check
|
Shipped in v0.9.120 (authorship-preserving cherry-pick). This also turned out to be the root-cause fix for the watch-test flakiness under the parallel suite — the global |
What does this PR do?
Fixes intermittent failures in the watcher tests, which have made CI red on
several PRs since the suite went parallel (013a646):
Example: this run on #5446,
with 7 failures in two files.
drive_watchdidmonkeypatch.setattr(watch_mod.time, "sleep", pump). That isthe shared
timemodule, sotime.sleepchanged for the whole process:It is a race with
gitexiting, so load makes it likelier. The helper nowreplaces the name
timeinwatch.pyonly.Marking these tests
serialwould not be enough: on v8 the two files alsofailed without xdist, in 8 of 8 runs on a machine under CPU load.
Type of change
Verification & Invariants
The invariant: the helper's clock controls only
watch()'s own loop. Anythingelse that sleeps during a rebuild gets the real clock.
Merge Danger
Door: two-way. Only
tests/test_language_override_lifecycle.pychanges.Blast radius: the tests that use
drive_watch, in two files.Limitations
watch.pystarts using anothertimefunction, the helper's stand-inneeds it too. The tests would fail with
AttributeError.subprocesswaits do. Windows waitsdifferently, so it would not catch this there.
How was this tested?
The new test starts a child that closes its pipes and lives 0.3 s longer, so
subprocesshas to sleep during the rebuild.A trace of 4 parallel v8 runs had 17 test failures, and every unexpected sleep
came from
_git_head. The full suite at-n 4also passed once on v8, so onegreen run alone proves little.
Python 3.13 on Linux. Not tested: Windows.
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no skill fragments touched.)