Repository navigation
feat(devtools): add devtools test focused runner so agents avoid raw pytest - #1786
Conversation
…w pytest Problem: devtools exposes `verify` (the full gate) but no comfortable way to run a focused selection, so agents reach for raw pytest and hand-roll worker flags, env, and tmpfs handling. That ad-hoc path is how a recent session ended up launching overlapping suites that raced on shared test state. What changed: - New `devtools test <pytest args>` command (devtools/run_tests.py). Forwards any selection (paths, -k/-m, -x, …) to pytest with the managed environment (POLYLOGUE_ROOT + repo-local pycache), a single-process worker default (-n 0; override via -n or POLYLOGUE_PYTEST_WORKERS), and live streamed output. - Checkout-scoped flock serializes overlapping `devtools test` runs so two suites from the same checkout don't burn CPU racing. Concurrency is already correctness-safe at the conftest level (#1785 per-run basetemp); this lock is the throughput guard. POLYLOGUE_TEST_NO_LOCK=1 bypasses it. - Registered in the command catalog (featured); regenerated docs/devtools.md and AGENTS.md. TESTING.md now steers the inner loop to `devtools test`. Verification: - nix develop -c devtools test tests/unit/devtools/test_run_tests.py -> 7 passed (dogfooded; single-process). - Two concurrent `devtools test` on the same selection: exactly one printed "waiting for in-flight run", both passed (lock serializes). - nix develop -c devtools verify --quick -> EXIT 0 (ruff/mypy/render-all/ verify-doc-commands and all gates green). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Warning Review limit reached
More reviews will be available in 36 minutes and 17 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new focused test runner, devtools test, to route inner-loop pytest selections through Polylogue’s managed devtools harness (parity env setup, single-process default, and checkout-scoped serialization), reducing ad-hoc raw pytest usage and preventing overlapping runs from the same checkout.
Changes:
- Added
devtools testimplementation (devtools/run_tests.py) with managed environment, default-n 0, optional worker override, and a checkout-scopedflock. - Registered
devtools testin the devtools command catalog and updated developer documentation to steer inner-loop testing to it. - Added unit tests covering command construction, selection guardrails, dispatch
--jsonstripping, exit-code passthrough, and managed env contents.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
devtools/run_tests.py |
Implements the new devtools test runner (env parity, worker defaulting, lock, pytest invocation). |
devtools/command_catalog.py |
Registers devtools test as a featured verification command. |
tests/unit/devtools/test_run_tests.py |
Adds unit coverage for devtools test behavior and guardrails. |
TESTING.md |
Updates testing guidance to prefer devtools test for focused runs. |
docs/devtools.md |
Documents devtools test among recommended devtools commands. |
AGENTS.md |
Regenerates agent guidance to prefer devtools test for focused runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with _LOCK_PATH.open("a+") as handle: | ||
| try: | ||
| fcntl.flock(handle.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) | ||
| except OSError: |
Summary
Adds
devtools test <pytest args>— a focused inner-loop runner that routes aselection through the managed harness, so agents and humans never hand-roll raw
pytest. Complementsdevtools verify(the full gate); it is not a substitute.Problem
devtoolsowned the full verification gate (verify) but had no comfortableentrypoint for "run this file /
-kexpr / directory." The result: agents reachfor raw
pytest, hand-rolling worker counts, env, and tmpfs handling — exactlythe ad-hoc path that, in a recent session, led to launching overlapping suites
that raced on shared test state and produced false failures.
Solution
devtools/run_tests.py(devtools test):-k/-m,-x, …) to pytest via thecontrol-plane dispatch's existing passthrough (
allow_extra_args/ignore_unknown_options).verify(POLYLOGUE_ROOT,POLYLOGUE_REPO_ROOT, repo-localPYTHONPYCACHEPREFIX).-n 0) for fast focused runs; override with anexplicit
-norPOLYLOGUE_PYTEST_WORKERS.verify, which captures for aggregation).flockserializes overlappingdevtools testruns so twosuites from one checkout don't burn CPU racing. Correctness under concurrency
is already guaranteed by the per-run tmpfs basetemp (fix(tests): isolate concurrent pytest runs with per-run tmpfs basetemp #1785); this lock is the
throughput guard.
POLYLOGUE_TEST_NO_LOCK=1bypasses it.suite — that's
devtools verify).Registered as a featured catalog command;
docs/devtools.md+AGENTS.mdregenerated;
TESTING.mdsteers the inner loop todevtools test.Verification
New unit tests in
tests/unit/devtools/test_run_tests.pycover worker-defaultand override,
--jsonstripping, the no-selection guard, exit-codepassthrough, and managed-env contents.