| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # added 2026-03-25 by Codex |
| 3 | # This file is part of the liblognorm project, released under ASL 2.0 |
| 4 | # |
| 5 | # Helper for developers and AI agents validating parser changes. |
| 6 | # |
| 7 | # This is intentionally kept outside of ./tests because it is not part of the |
| 8 | # project testbench itself. It is workflow tooling that enforces the local |
| 9 | # validation policy documented in AGENTS.md: |
| 10 | # - rebuild src/ln_test before running parser tests |
| 11 | # - build tests/json_eq when JSON comparison helpers are needed |
| 12 | # - run the whole parser-family test set for a parser name, including |
| 13 | # *_jsoncnf.sh, *_v1.sh, and edge-case variants when present |
| 14 | # |
| 15 | # Usage: |
| 16 | # ai/run-parser-family.sh checkpoint-lea |
| 17 | # ai/run-parser-family.sh field_checkpoint-lea.sh |
| 18 | # |
| 19 | # The parser name is normalized to the shell test prefix field_<parser>* and |
| 20 | # every matching shell test in ./tests is executed sequentially. |
| 21 | |
| 22 | set -euo pipefail |
| 23 | |
| 24 | usagescip-shell shell shell-project 0.0.0 usage().() { |
| 25 | printfscip-shell system . . printf. 'Usage: %s <parser-name>\n' "$0" >&2 |
| 26 | printfscip-shell system . . printf. 'Example: %s checkpoint-lea\n' "$0" >&2 |
| 27 | exit 1 |
| 28 | } |
| 29 | |
| 30 | [scip-shell system . . `[`. $# -eq 1 ] || usagescip-shell shell shell-project 0.0.0 usage(). |
| 31 | |
| 32 | parser_name="$1" |
| 33 | parser_name="${parser_name#field_}" |
| 34 | parser_name="${parser_name%.sh}" |
| 35 | |
| 36 | script_dir="$(cd "$(dirnamescip-shell system . . dirname. "$0")" && pwdscip-shell system . . pwd.)" |
| 37 | repo_root="$(cd "${script_dir}/.." && pwdscip-shell system . . pwd.)" |
| 38 | tests_dir="${repo_root}/tests" |
| 39 | |
| 40 | mapfile -t tests < <( |
| 41 | cd "${tests_dir}" |
| 42 | printfscip-shell system . . printf. '%s\n' field_"${parser_name}"*.sh | sortscip-shell system . . sort. |
| 43 | ) |
| 44 | |
| 45 | if [scip-shell system . . `[`. "${#tests[@]}" -eq 0 ] || [scip-shell system . . `[`. "${tests[0]}" = "field_${parser_name}*.sh" ]; then |
| 46 | printfscip-shell system . . printf. 'No parser-family tests found for %s\n' "${parser_name}" >&2 |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
| 50 | makescip-shell system . . make. -C "${repo_root}/src" ln_test |
| 51 | makescip-shell system . . make. -C "${tests_dir}" json_eq |
| 52 | |
| 53 | for test_name in "${tests[@]}"; do |
| 54 | ( |
| 55 | cd "${tests_dir}" |
| 56 | srcdir=. top_builddir=.. bashscip-shell system . . bash. "./${test_name}" |
| 57 | ) |
| 58 | done |