Skip to content

Instantly share code, notes, and snippets.

@olivergondza
Created October 25, 2021 12:15
Show Gist options
  • Save olivergondza/2daa9a6cd62b0543915b33c8e8c0037b to your computer and use it in GitHub Desktop.
Save olivergondza/2daa9a6cd62b0543915b33c8e8c0037b to your computer and use it in GitHub Desktop.
bats-safemode-reproducer
function foo() {
echo "$1" | grep bar # Fail if the input does not contain 'bar'
echo "end"
}
#!/usr/bin/env bash
set -euo pipefail
source "./lib.sh"
foo "barista"
echo "barista == $?"
foo "waitress"
echo "waitress == $?"
#!/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