| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | # Copyright 2025 The go-yaml Project Contributors |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | # Show test count statistics for go-yaml |
| 7 | |
| 8 | set -euo pipefail |
| 9 | |
| 10 | # shellcheck disable=SC1091 |
| 11 | source "$(dirnamescip-shell system . . dirname. "$0")/common.bash" |
| 12 | |
| 13 | mainscip-shell shell shell-project 0.0.0 main().() ( |
| 14 | echoscip-shell system . . echo. '=== TEST COUNT SUMMARY ===' |
| 15 | echoscip-shell system . . echo. |
| 16 | |
| 17 | # Count YAML test cases |
| 18 | echoscip-shell system . . echo. 'Data-driven YAML test cases:' |
| 19 | decode_count=$(grepscip-shell system . . grep. -c '^- decode:' testdata/decode.yaml) |
| 20 | encode_count=$(grepscip-shell system . . grep. -c '^- encode:' testdata/encode.yaml) |
| 21 | error_count=$(grepscip-shell system . . grep. -c '^- unmarshal-error:' testdata/unmarshal_errors.yaml) |
| 22 | yaml_total=$((decode_count + encode_count + error_count)) |
| 23 | |
| 24 | printfscip-shell system . . printf. ' %-22s %3d\n' 'decode.yaml:' "$decode_count" |
| 25 | printfscip-shell system . . printf. ' %-22s %3d\n' 'encode.yaml:' "$encode_count" |
| 26 | printfscip-shell system . . printf. ' %-22s %3d\n' 'unmarshal_errors.yaml:' "$error_count" |
| 27 | printfscip-shell system . . printf. ' %-22s %3d\n' 'Subtotal:' "$yaml_total" |
| 28 | echoscip-shell system . . echo. |
| 29 | |
| 30 | # Count Go test cases |
| 31 | echoscip-shell system . . echo. 'Go hardcoded test cases:' |
| 32 | unmarshal_count=$(awkscip-shell system . . awk. '/^var unmarshalTests/,/^}$/{if(/^ {$/){count++}}END{print count}scip-shell filesystem . . `/^var unmarshalTests/,/^}$/{if(/^ {$/){count++}}END{print count}`.' decode_test.go) |
| 33 | marshal_count=$(awkscip-shell system . . awk. '/^var marshalTests/,/^}$/{if(/^ {$/){count++}}END{print count}scip-shell filesystem . . `/^var marshalTests/,/^}$/{if(/^ {$/){count++}}END{print count}`.' encode_test.go) |
| 34 | go_total=$((unmarshal_count + marshal_count)) |
| 35 | |
| 36 | printfscip-shell system . . printf. ' %-22s %3d\n' 'unmarshalTests:' "$unmarshal_count" |
| 37 | printfscip-shell system . . printf. ' %-22s %3d\n' 'marshalTests:' "$marshal_count" |
| 38 | printfscip-shell system . . printf. ' %-22s %3d\n' 'Subtotal:' "$go_total" |
| 39 | echoscip-shell system . . echo. |
| 40 | |
| 41 | # Total test cases |
| 42 | local case_total |
| 43 | case_total=$((yaml_total + go_total)) |
| 44 | printfscip-shell system . . printf. '%-24s %3d\n' 'Test case total:' "$case_total" |
| 45 | echoscip-shell system . . echo. |
| 46 | |
| 47 | # Count test executions (requires running tests) |
| 48 | echoscip-shell system . . echo. 'Test executions (running tests to count...):' |
| 49 | test_output=$(goscip-shell system . . go. test -v . ./internal/... -vet=off 2>&1) |
| 50 | run_count=$(<<< "$test_output" grepscip-shell system . . grep. -c '^=== RUN' || truescip-shell system . . true.) |
| 51 | pass_count=$(<<< "$test_output" grepscip-shell system . . grep. -c 'PASS:' || truescip-shell system . . true.) |
| 52 | |
| 53 | printfscip-shell system . . printf. ' %-22s %4d\n' 'Unit test runs:' "$run_count" |
| 54 | printfscip-shell system . . printf. ' %-22s %4d\n' 'Unit test passes:' "$pass_count" |
| 55 | echoscip-shell system . . echo. |
| 56 | ) |
| 57 | |
| 58 | mainscip-shell shell shell-project 0.0.0 main(). "$@" |