#!/bin/bash set -euo pipefail # For each files in tests/queries/*, mount that parquet file, run the query, and compare # its output. run_query() { file=${1:?must provide testcase file} query=${2:?must provide query to run} basename=$(basename "$file") cat < testcases.txt if [ ! -s testcases.txt ]; then echo "no matching testcases found" exit 1 fi if [ "$(cat testcases.txt | wc -l)" == "1" ]; then set -x gdb -ex run --args "$root"/sqlite/sqlite3 -init testcase-cmds.txt else while read -r file; do echo "Testing: $file" query=$(head -n1 "$file" | tail -n1) tail -n+2 "$file" > testcase-expected.txt run_query "$file" "$query" > testcase-cmds.txt if ! "$root"/sqlite/sqlite3 -init testcase-cmds.txt < /dev/null > testcase-stdout.txt 2> testcase-stderr.txt; then echo "...FAILED; check testcase-{out,err}.txt" >&2 exit 1 fi diff testcase-out.txt testcase-expected.txt done < testcases.txt fi } main "$@"