test: stabilize timing-sensitive checks - #3
Merged
Conversation
dejay-vu
marked this pull request as ready for review
July 13, 2026 22:50
There was a problem hiding this comment.
Pull request overview
This PR stabilizes timing-sensitive test assertions by synchronizing on the actual states under test (process lifecycle, UI mounting, and CPU-time performance budgets) and reduces duplicated CI runs by limiting push workflows to main.
Changes:
- Add a helper to wait for background login-build processes to exit before asserting cleanup.
- Switch the “1,000 runs query + render” performance budget to use process CPU time (and rename the test accordingly).
- Add extra synchronization in a Textual modal flow, and restrict CI
push/pull_requesttriggers tomain.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/unit/test_env_executors.py | Adds a helper to wait for background process exit before cleanup assertions. |
| tests/tui/test_pilot.py | Adds extra UI synchronization to avoid modal/child-mount race before clicking. |
| tests/perf/test_ux_budgets.py | Measures query/render budget using CPU time and renames the test to reflect that. |
| .github/workflows/ci.yml | Reduces CI noise by running push CI only on main and scoping PR CI to main. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+141
to
+149
| def _wait_for_process_exit(pid: int, *, timeout: float = 5.0) -> None: | ||
| deadline = time.monotonic() + timeout | ||
| while time.monotonic() < deadline: | ||
| try: | ||
| os.kill(pid, 0) | ||
| except OSError: | ||
| return | ||
| time.sleep(0.05) | ||
| pytest.fail(f"background process {pid} did not exit within {timeout:.1f}s") |
dejay-vu
added a commit
that referenced
this pull request
Jul 14, 2026
## Summary - reject non-positive process IDs before probing for process exit - treat only `ProcessLookupError` as evidence that the process is gone - fail explicitly when `os.kill(pid, 0)` raises another `OSError` - wait for the asynchronous GC preview callback before inspecting its modal ## Why The process-exit helper follows up on Copilot feedback from PR #3: catching every `OSError` could incorrectly pass when a process still existed but could not be inspected. The Python 3.14 check also exposed a separate TUI race where the test could inspect the screen before the GC callback had pushed the confirmation modal. ## Impact Production behavior is unchanged. These tests now distinguish a missing process from a failed process probe and synchronize with both the GC callback and modal mounting before making assertions. ## Validation - GC preview test passed 20 consecutive runs - targeted background login-build test passed - `conda run -n slurmdeck-dev ruff format .` - `conda run -n slurmdeck-dev ruff check .` - `conda run -n slurmdeck-dev mypy` - `conda run -n slurmdeck-dev python -m pytest -q` (`510 passed`) - `git diff --check`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mainwhile retaining pull-request CI for changes targetingmainWhy
PR #2 exposed three timing-sensitive failures that passed on the same commit in other matrix runs: a near-threshold performance sample, a short process-reaping window, and a modal child-mount race. Feature branches also produced duplicate push and pull-request matrices, increasing CI noise and cost.
Impact
Runtime behavior is unchanged. The test suite preserves its existing performance threshold and behavioral assertions while synchronizing on the states it actually depends on. CI continues to validate every pull request and every update to
mainwithout duplicate feature-branch push runs.Validation
conda run -n slurmdeck-dev ruff format .conda run -n slurmdeck-dev ruff check .conda run -n slurmdeck-dev mypyconda run -n slurmdeck-dev python -m pytest -q(510 passed)yqgit diff --checkactionlintwas not run because it is not installed locally.