| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright 2025 The go-yaml Project Contributors |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | set -euo pipefail |
| 7 | |
| 8 | main() ( |
| 9 | type=$1 |
| 10 | |
| 11 | if [[ $type == all ]]; then |
| 12 | export RUNALL=1 |
| 13 | elif [[ $type == fail ]]; then |
| 14 | export RUNFAILING=1 |
| 15 | else |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | results=$( |
| 20 | go test ./yts -count=1 -v | |
| 21 | awk '/ --- (PASS|FAIL): / {print $2, $3}' |
| 22 | ) || true |
| 23 | |
| 24 | known_count=$(grep -c '' yts/known-failing-tests) |
| 25 | pass_count=$(grep -c '^PASS:' <<<"$results") |
| 26 | fail_count=$(grep -c '^FAIL:' <<<"$results") |
| 27 | |
| 28 | echo "PASS: $pass_count" |
| 29 | echo "FAIL: $fail_count (known: $known_count)" |
| 30 | |
| 31 | if [[ $type == fail ]] && [[ $pass_count -gt 0 ]]; then |
| 32 | echo "ERROR: Found passing tests among expected failures:" |
| 33 | grep '^PASS:' "$results" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | if [[ $fail_count != "$known_count" ]]; then |
| 38 | echo "ERROR: FAIL count ($fail_count) differs from expected $known_count" |
| 39 | exit 1 |
| 40 | fi |
| 41 | ) |
| 42 | |
| 43 | main "$@" |