Repository navigation
Commit 230a170
committed
fix(worker): move TOKEN_GOAT_NO_WORKER_SPAWN check to CLI entry point
Earlier this round the check landed first in ``worker.ensure_running``
(broke 2 spawn-respawn unit tests via the mocked ``spawn_detached``),
then in ``spawn_detached`` itself (broke 3 tests that test that
function's body via mocked ``Popen``), then in ``worker_daemon.run_daemon``
(broke 9 tests that drive ``run_daemon`` directly to verify its main
loop). Each tier of unit tests bypasses one more layer of the spawn
chain.
The clean break: put the check in ``cli.cmd_worker`` instead. This is
the function the subprocess command ``pythonw -m token_goat.cli worker
--daemon`` actually invokes when the spawn chain runs end-to-end.
Direct unit tests of ``ensure_running``, ``spawn_detached``, and
``run_daemon`` all skip this entry point — they call the lower-level
functions directly — so they remain unaffected. Only the real-spawn
path (``ensure_running`` → ``spawn_detached`` → ``Popen`` → child
process loads ``cli.py`` → ``cmd_worker`` → early-exit) sees the env
var.
Env-var propagation: ``subprocess.Popen`` inherits the parent's env by
default, so a test step that sets ``TOKEN_GOAT_NO_WORKER_SPAWN=1`` on
the workflow step propagates the var to every child process spawned
from it. The child ``pythonw -m token_goat.cli worker --daemon``
loads, reaches ``cmd_worker``, sees the var, and returns immediately
without entering the heartbeat loop. GitHub Actions on Windows can
then close the job object's descendants cleanly and the step
completes.
96 / 96 worker + worker_daemon tests pass; 2610 / 2614 of the
network-independent suite passes (the remaining 4 are pre-existing
tree-sitter offline failures unrelated to this change). Lint clean;
mypy adds zero new errors over baseline.1 parent 73da20d commit 230a170
2 files changed
Lines changed: 22 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1481 | 1481 | | |
1482 | 1482 | | |
1483 | 1483 | | |
1484 | | - | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
1485 | 1500 | | |
1486 | 1501 | | |
1487 | 1502 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1176 | 1176 | | |
1177 | 1177 | | |
1178 | 1178 | | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
1185 | 1185 | | |
1186 | 1186 | | |
1187 | 1187 | | |
| |||
1198 | 1198 | | |
1199 | 1199 | | |
1200 | 1200 | | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | 1201 | | |
1214 | 1202 | | |
1215 | 1203 | | |
| |||
0 commit comments