From e971edc0dd93b45f5bd0825fd46b300e22385a4d Mon Sep 17 00:00:00 2001 From: JYunth Date: Mon, 9 Nov 2026 16:22:12 +0530 Subject: [PATCH 1/2] loopguard: a heredoc's lines are not test runs status_of_tests split the raw command, so a heredoc line that starts with a test runner counted as a test run of its own. A turn whose last real run failed, followed by `gh pr create --body-file - <<'EOF'` with `pytest -q` in the body, was recorded as ended green, and the judge was told the last verification passed. It now drops heredoc bodies before splitting, as exit_status_covers already does. A runner that reads a heredoc (`pytest -q < ci.sh\nnpm test\nEOF") is None + + +@pytest.mark.parametrize("cmd", ["gh pr create --body-file - <<'EOF'\npytest -q\nEOF", + "gh issue comment 7 --body-file - < ci.sh\nnpm test\nEOF\npytest -q"]) +def test_a_runner_beside_a_heredoc_is_still_judged_by_its_status(cmd): + """A runner that reads a heredoc, or runs after one, is the last command: its status is the + tests' own.""" + assert turn.status_of_tests(cmd) == "own" + + TAP_FAILING = "# tests 9\n# suites 0\n# pass 8\n# fail 1\n# cancelled 0" diff --git a/tokeneconomizer/loopguard/turn.py b/tokeneconomizer/loopguard/turn.py index f973696..f942654 100644 --- a/tokeneconomizer/loopguard/turn.py +++ b/tokeneconomizer/loopguard/turn.py @@ -141,7 +141,7 @@ def status_of_tests(cmd): (Codex) is judged by its script.""" if not isinstance(cmd, str): return None - pieces, pipefail = _pieces(cmd) + pieces, pipefail = _pieces(_split_heredocs(cmd)[0]) found = None for i in range(0, len(pieces), 2): stage = pieces[i] From 66942914c350789a5bf2bddcc6a2d19e41e2b1f3 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 10 Nov 2026 09:15:01 -0800 Subject: [PATCH 2/2] loopguard: drop a Codex script's heredocs after the unwrap A heredoc that ends a bash -lc '