Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More negative test cases #22

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/00-intro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,21 @@ tests:
steps:
- exec: node1
run: rm -f repeat-test-file

- name: Repeat on non-zero exit code
exec: node1
repeat: { retries: 2, interval: '1s' }
run: |
if [ ! -f repeat-test-file ]; then
touch repeat-test-file
exit 1
fi

- exec: node1
run: rm -f repeat-test-file

- name: Repeat on failed expect assertion
exec: node1
repeat: { retries: 2, interval: '1s' }
run: |
if [ ! -f repeat-test-file ]; then
Expand All @@ -86,5 +100,6 @@ tests:
fi
expect:
- step.stdout == "Repeated successfully"

- exec: node1
run: rm -f repeat-test-file
29 changes: 26 additions & 3 deletions examples/01-fails.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tests:
run: echo 'This step is skipped'

maybe-skipped:
depends: "fail-signal" # any failing test would do
name: Skipped test (unless running with --continue-on-error)
steps:
- exec: node1
Expand All @@ -35,10 +36,32 @@ tests:
- exec: node2
run: /bin/true

fail-expressions:
name: Test thrown exception in expressions
fail-expect:
name: Failing due to unmet expect condition
steps:
- exec: node1
env:
run: /bin/true
expect:
- 1 == 2

fail-if-throws:
name: Test thrown exception in expressions ('if')
steps:
- if: throw("Intentional Failure")
exec: node1
run: /bin/true

fail-env-throws:
name: Test thrown exception in expressions ('env')
steps:
- env:
FOO: ${{ throw("Intentional Failure") }}
exec: node1
run: /bin/true

fail-expect-throws:
name: Test thrown exception in expressions ('expect')
steps:
- exec: node1
run: /bin/true
expect: throw("Intentional Failure")
2 changes: 1 addition & 1 deletion test/runexamples
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ eopt="--environ-file ${repo_root}/examples/03-env-file"
up

check 5 0 "${copt} " 00-intro.yaml
check 6 4 "${copt} " 00-intro.yaml 01-fails.yaml
check 6 7 "${copt} " 00-intro.yaml 01-fails.yaml
check 5 1 " " 00-intro.yaml 01-fails.yaml
check 12 0 "${copt} " 02-deps.yaml
check 4 0 "${copt} ${eopt}" 03-env.yaml
Expand Down
Loading