Skip to content

Commit 167ea0d

Browse files
committed
Extend /run-tests skill with dev-workflow helpers
Add pre-flight import/collect checks, a mod-to-test mapping table, `--lf` re-run patterns, and a known-flaky test list to avoid wasted investigation time. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code
1 parent e121e09 commit 167ea0d

File tree

1 file changed

+77
-8
lines changed

1 file changed

+77
-8
lines changed

.claude/skills/run-tests/SKILL.md

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,44 @@ python -m pytest tests/ -x --tb=short --no-header --tpt-proto uds
8888
python -m pytest tests/ -x --tb=short --no-header -k "cancel and not slow"
8989
```
9090

91-
## 3. Run and report
91+
## 3. Pre-flight checks (before running tests)
92+
93+
Always run these first, especially after refactors or
94+
module moves — they catch import errors instantly:
95+
96+
```sh
97+
# 1. package import smoke check
98+
python -c 'import tractor; print(tractor)'
99+
100+
# 2. verify all tests collect (no import errors)
101+
python -m pytest tests/ -x -q --co 2>&1 | tail -5
102+
```
103+
104+
If either fails, fix the import error before running
105+
any actual tests.
106+
107+
## 4. Run and report
92108

93109
- Run the constructed command.
94110
- Use a timeout of **600000ms** (10min) for full suite
95111
runs, **120000ms** (2min) for single-file runs.
96112
- If the suite is large (full `tests/`), consider running
97113
in the background and checking output when done.
114+
- Use `--lf` (last-failed) to re-run only previously
115+
failing tests when iterating on a fix.
98116

99117
### On failure:
100118
- Show the failing test name(s) and short traceback.
101119
- If the failure looks related to recent changes, point
102120
out the likely cause and suggest a fix.
103-
- If the failure looks like a pre-existing flaky test
104-
(e.g. `TooSlowError`, pexpect `TIMEOUT`), note that.
121+
- **Check the known-flaky list** (section 8) before
122+
investigating — don't waste time on pre-existing
123+
timeout issues.
105124

106125
### On success:
107126
- Report the pass/fail/skip counts concisely.
108127

109-
## 4. Test directory layout (reference)
128+
## 5. Test directory layout (reference)
110129

111130
```
112131
tests/
@@ -126,13 +145,63 @@ tests/
126145
└── ...
127146
```
128147

129-
## 5. Quick-check shortcuts
148+
## 6. Change-type → test mapping
130149

131-
For fast verification after refactors, suggest running
132-
the "core" subset first:
150+
After modifying specific modules, run the corresponding
151+
test subset first for fast feedback:
133152

153+
| Changed module(s) | Run these tests first |
154+
|---|---|
155+
| `runtime/_runtime.py`, `runtime/_state.py` | `test_local.py test_rpc.py test_spawning.py test_root_runtime.py` |
156+
| `discovery/` (`_registry`, `_discovery`, `_addr`) | `test_discovery.py test_multi_program.py test_local.py` |
157+
| `_context.py`, `_streaming.py` | `test_context_stream_semantics.py test_advanced_streaming.py` |
158+
| `ipc/` (`_chan`, `_server`, `_transport`) | `tests/ipc/ test_2way.py` |
159+
| `runtime/_portal.py`, `runtime/_rpc.py` | `test_rpc.py test_cancellation.py` |
160+
| `spawn/` (`_spawn`, `_entry`) | `test_spawning.py test_multi_program.py` |
161+
| `devx/debug/` | `tests/devx/test_debugger.py` (slow!) |
162+
| `to_asyncio.py` | `test_infected_asyncio.py test_root_infect_asyncio.py` |
163+
| `msg/` | `tests/msg/` |
164+
| `_exceptions.py` | `test_remote_exc_relay.py test_inter_peer_cancellation.py` |
165+
| `runtime/_supervise.py` | `test_cancellation.py test_spawning.py` |
166+
167+
## 7. Quick-check shortcuts
168+
169+
### After refactors (fastest first-pass):
134170
```sh
171+
# import + collect check
172+
python -c 'import tractor' && python -m pytest tests/ -x -q --co 2>&1 | tail -3
173+
174+
# core subset (~10s)
135175
python -m pytest tests/test_local.py tests/test_rpc.py tests/test_spawning.py tests/test_discovery.py -x --tb=short --no-header
136176
```
137177

138-
Then expand to the full suite if those pass.
178+
### Re-run last failures only:
179+
```sh
180+
python -m pytest --lf -x --tb=short --no-header
181+
```
182+
183+
### Full suite in background:
184+
When core tests pass and you want full coverage while
185+
continuing other work, run in background:
186+
```sh
187+
python -m pytest tests/ -x --tb=short --no-header -q
188+
```
189+
(use `run_in_background=true` on the Bash tool)
190+
191+
## 8. Known flaky tests
192+
193+
These tests have **pre-existing** timing/environment
194+
sensitivity. If they fail with `TooSlowError` or
195+
pexpect `TIMEOUT`, they are almost certainly NOT caused
196+
by your changes — note them and move on.
197+
198+
| Test | Typical error | Notes |
199+
|---|---|---|
200+
| `devx/test_debugger.py::test_multi_nested_subactors_error_through_nurseries` | pexpect TIMEOUT | Debugger pexpect timing |
201+
| `test_cancellation.py::test_cancel_via_SIGINT_other_task` | TooSlowError | Signal handling race |
202+
| `test_inter_peer_cancellation.py::test_peer_spawns_and_cancels_service_subactor` | TooSlowError | Async timing (both param variants) |
203+
| `test_docs_examples.py::test_example[we_are_processes.py]` | `assert None == 0` | `__main__` missing `__file__` in subproc |
204+
205+
**Rule of thumb**: if a test fails with `TooSlowError`,
206+
`trio.TooSlowError`, or `pexpect.TIMEOUT` and you didn't
207+
touch the relevant code path, it's flaky — skip it.

0 commit comments

Comments
 (0)