Created
October 25, 2021 12:15
-
-
Save olivergondza/2daa9a6cd62b0543915b33c8e8c0037b to your computer and use it in GitHub Desktop.
bats-safemode-reproducer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo() { | |
echo "$1" | grep bar # Fail if the input does not contain 'bar' | |
echo "end" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
source "./lib.sh" | |
foo "barista" | |
echo "barista == $?" | |
foo "waitress" | |
echo "waitress == $?" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bats | |
setup() { | |
load '/usr/lib/bats-support/load.bash' | |
load '/usr/lib/bats-assert/load.bash' | |
set -euo pipefail | |
source "./lib.sh" | |
} | |
@test test_foo { | |
run foo "barista" | |
assert_success | |
assert_output $'barista\nend' | |
run foo "waitress" | |
assert_failure | |
assert_output '' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment