#!/bin/bash # Tests for jetc --lint-sql (docs/design-sql-bound-parameters.md, phase 2). # Runs the lint over tests/lintsql/ and compares with the .expected files. # Needs no database. set -u T="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" JC="$(cd "$T/.." && pwd)" WORK="$(mktemp -d)" trap 'rm -rf "$WORK"' EXIT fail=0 g++ -g -std=c++23 -o "$WORK/jetc" "$JC/jetc/jetc.cpp" "$JC/jetc/JetParser.cpp" "$JC/jetc/JetCodegen.cpp" "$JC/jetc/JetLint.cpp" || exit 1 # check NAME EXPECTED_EXIT ARGS... - output is compared with lintsql/NAME.expected check() { local name="$1" want="$2"; shift 2 (cd "$T/lintsql" && "$WORK/jetc" --lint-sql "$@") > "$WORK/$name.out" 2>&1 local got=$? if [ "$got" != "$want" ]; then echo "FAIL $name: exit $got, expected $want"; fail=1 elif ! diff -u "$T/lintsql/$name.expected" "$WORK/$name.out"; then echo "FAIL $name: output differs"; fail=1 else echo "PASS $name" fi } check site 1 site check strict 1 --strict site check clean 0 clean check missing 2 clean no-such-dir [ $fail = 0 ] && echo "ALL PASSED" || echo "FAILURES" exit $fail