diff --git a/tests/test_live_core.py b/tests/test_live_core.py index 4dae487..0c6b593 100644 --- a/tests/test_live_core.py +++ b/tests/test_live_core.py @@ -1336,6 +1336,44 @@ def test_a_non_test_command_mentioning_a_runner_is_not_a_verification(cmd): assert g.verifications == 1 and not g.resolved_proxy() +def test_a_heredoc_writing_a_script_runs_no_tests(): + assert turn.status_of_tests("cat < 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" + + +@pytest.mark.parametrize("cmd, want", [ + ("bash -lc 'pytest -q <'`. A heredoc that ends the script closes on `EOF'` there, + not on a line of its own, so its body is left out after the unwrap: the run before it still + counts, and a runner named in its body still does not.""" + assert turn.status_of_tests(cmd) == want + + 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..cf2f2e9 100644 --- a/tokeneconomizer/loopguard/turn.py +++ b/tokeneconomizer/loopguard/turn.py @@ -71,8 +71,9 @@ def _pieces(cmd): """`cmd` as its commands and the separators between them (`[cmd, sep, cmd, ...]`), with - quoted text masked, and whether it sets `pipefail`. A command recorded as `bash -lc - '