#!/usr/bin/env bash set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) root=$(mktemp -d) trap 'rm -rf "$root"' EXIT mkdir -p "$root/bin" cat >"$root/bin/go" <<'EOF' #!/usr/bin/env bash printf '%s\n' "$FAKE_GO_OUTPUT" exit "$FAKE_GO_STATUS" EOF chmod +x "$root/bin/go" export PATH="$root/bin:$PATH" cd "$root" check() { local name=$1 status=$2 output=$3 want=$4 message=$5 actual=0 FAKE_GO_STATUS="$status" FAKE_GO_OUTPUT="$output" bash "$here/known-bugs.sh" >result 2>&1 <<'LIST' || actual=$? #1 ./fixture TestKnown LIST if [ "$actual" != "$want" ] || ! grep -q "$message" result; then echo "FAIL: $name (exit $actual, expected $want)"; cat result; exit 1 fi if [ "$message" != 'now PASSES' ] && grep -q 'now PASSES' result; then echo "FAIL: $name falsely called fixed"; cat result; exit 1 fi } check failure 1 '--- FAIL: TestKnown (0.00s)' 0 'still fails' check pass 0 '--- PASS: TestKnown (0.00s)' 1 'now PASSES' check missing 0 'ok fixture [no tests to run]' 1 'did not run' check skipped 0 '--- SKIP: TestKnown (0.00s)' 1 'did not run' check build 1 'FAIL fixture [build failed]' 1 'failed to build' check other 1 '--- FAIL: TestKnownOther (0.00s)' 1 'did not run' check subtest 1 ' --- FAIL: TestKnown/child (0.00s)' 1 'did not run' check interrupted 1 '=== RUN TestKnown' 1 'did not run' check inconsistent 0 '--- FAIL: TestKnown (0.00s)' 1 'did not run' echo 'known-bugs: exact failure, pass, missing, skip, build, other test and interruption controls PASS'