Skip to content

Commit 40e9bb7

Browse files
doquanghuyclaude
andcommitted
test: portable exit-code step commands + cover resume failed->exit-1
Address review (#2959): replace non-portable run: 'true'/'false' with 'exit 0'/'exit 1' (Windows cmd.exe has no true/false builtins under shell=True), and add an end-to-end 'workflow resume' test asserting a resumed failed run exits non-zero. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent df51dea commit 40e9bb7

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

tests/test_workflows.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3958,7 +3958,7 @@ class TestWorkflowRunExitCodes:
39583958
steps:
39593959
- id: fine
39603960
type: shell
3961-
run: "true"
3961+
run: "exit 0"
39623962
"""
39633963

39643964
_WF_FAIL = """
@@ -3970,7 +3970,7 @@ class TestWorkflowRunExitCodes:
39703970
steps:
39713971
- id: boom
39723972
type: shell
3973-
run: "false"
3973+
run: "exit 1"
39743974
"""
39753975

39763976
def _write(self, tmp_path, content):
@@ -4009,6 +4009,30 @@ def test_run_failed_exits_nonzero_with_json(self, tmp_path, monkeypatch):
40094009
app,
40104010
["workflow", "run", str(self._write(tmp_path, self._WF_FAIL)), "--json"],
40114011
)
4012+
assert result.exit_code == 1, result.stdout
40124013
payload = _json.loads(result.stdout)
40134014
assert payload["status"] == "failed"
4014-
assert result.exit_code == 1
4015+
4016+
def test_resume_failed_run_exits_nonzero(self, tmp_path, monkeypatch):
4017+
# End-to-end coverage for the `workflow resume` exit-code mapping:
4018+
# resuming a run whose outcome is still `failed` must exit non-zero,
4019+
# mirroring `workflow run`. Resume re-executes the failed step, which
4020+
# fails again, so the resumed outcome stays `failed`.
4021+
import json as _json
4022+
from typer.testing import CliRunner
4023+
from specify_cli import app
4024+
4025+
monkeypatch.chdir(tmp_path)
4026+
(tmp_path / ".specify").mkdir() # `workflow resume` requires a project
4027+
runner = CliRunner()
4028+
run = runner.invoke(
4029+
app,
4030+
["workflow", "run", str(self._write(tmp_path, self._WF_FAIL)), "--json"],
4031+
)
4032+
assert run.exit_code == 1, run.stdout
4033+
run_id = _json.loads(run.stdout)["run_id"]
4034+
4035+
resumed = runner.invoke(app, ["workflow", "resume", run_id, "--json"])
4036+
assert resumed.exit_code == 1, resumed.stdout
4037+
payload = _json.loads(resumed.stdout)
4038+
assert payload["status"] == "failed"

0 commit comments

Comments
 (0)