2018-03-05 02:05:26 +00:00
|
|
|
#!/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}
|
|
|
|
parquet_file=${2:?must provide parquet file to load}
|
|
|
|
query=${3:?must provide query to run}
|
|
|
|
basename=$(basename "$file")
|
|
|
|
cat <<EOF
|
|
|
|
.load parquet/libparquet
|
|
|
|
.testcase $basename
|
|
|
|
.bail on
|
|
|
|
CREATE VIRTUAL TABLE test USING parquet('parquet-generator/$parquet_file');
|
|
|
|
$query
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
root=$(dirname "${BASH_SOURCE[0]}")/..
|
|
|
|
root=$(readlink -f "$root")
|
|
|
|
cd "$root"
|
|
|
|
|
2018-03-05 03:29:35 +00:00
|
|
|
queries=$(find tests/queries -type f -name '*.sql' | sort)
|
2018-03-05 02:05:26 +00:00
|
|
|
while read -r file; do
|
|
|
|
echo "Testing: $file"
|
|
|
|
parquet_file=$(head -n1 "$file")
|
|
|
|
query=$(head -n2 "$file" | tail -n1)
|
|
|
|
results=$(tail -n+3 "$file")
|
2018-03-05 03:29:35 +00:00
|
|
|
if ! "$root"/sqlite/sqlite3 -init <(run_query "$file" "$parquet_file" "$query") < /dev/null > testcase-stdout.txt 2> testcase-stderr.txt; then
|
2018-03-05 02:05:26 +00:00
|
|
|
echo "...FAILED; check testcase-{out,err}.txt" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
diff testcase-out.txt <(echo "$results")
|
|
|
|
done < <(echo "$queries")
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|