Skip to content

Commit

Permalink
Support commands that are expected to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorj committed Feb 26, 2024
1 parent d4681de commit 5319e36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions example/skewer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ steps:
- title: Fail on demand
commands:
west:
- run: |
if [ -n "${SKEWER_FAIL}" ]; then expr 1 / 0; fi
- run: "if [ -n \"${SKEWER_FAIL}\" ]; then expr 1 / 0; fi"
- title: Fail expectedly
commands:
west:
- run: "expr 1 / 0"
expect_failure: true
- standard: hello_world/expose_the_backend
- standard: hello_world/access_the_frontend
- standard: hello_world/cleaning_up
Expand Down
12 changes: 11 additions & 1 deletion python/skewer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,16 @@ def run_step(model, step, work_dir, check=True):
await_console_ok()

if command.run:
run(command.run.replace("~", work_dir), shell=True, check=check)
proc = run(command.run.replace("~", work_dir), shell=True, check=False)

if command.expect_failure:
if proc.exit_code == 0:
fail("A command expected to fail did not fail")

continue

if check and proc.exit_code > 0:
raise PlanoProcessError(proc)

def pause_for_demo(model):
notice("Pausing for demo time")
Expand Down Expand Up @@ -675,6 +684,7 @@ def commands(self):

class Command:
run = object_property("run")
expect_failure = object_property("expect_failure", False)
apply = object_property("apply")
output = object_property("output")
await_resource = object_property("await_resource")
Expand Down

0 comments on commit 5319e36

Please sign in to comment.