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}
|
2018-03-08 01:20:34 +00:00
|
|
|
query=${2:?must provide query to run}
|
2018-03-05 02:05:26 +00:00
|
|
|
basename=$(basename "$file")
|
|
|
|
cat <<EOF
|
|
|
|
.load parquet/libparquet
|
|
|
|
.testcase $basename
|
|
|
|
.bail on
|
2018-03-08 01:20:34 +00:00
|
|
|
CREATE VIRTUAL TABLE nulls USING parquet('$root/parquet-generator/100-rows-nulls.parquet');
|
|
|
|
CREATE VIRTUAL TABLE no_nulls1 USING parquet('$root/parquet-generator/100-rows-1.parquet');
|
|
|
|
CREATE VIRTUAL TABLE no_nulls2 USING parquet('$root/parquet-generator/100-rows-10.parquet');
|
2018-03-10 18:25:13 +00:00
|
|
|
$query;
|
|
|
|
.output
|
2018-03-05 02:05:26 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
root=$(dirname "${BASH_SOURCE[0]}")/..
|
|
|
|
root=$(readlink -f "$root")
|
|
|
|
cd "$root"
|
|
|
|
|
2018-03-10 16:54:36 +00:00
|
|
|
find_cmd=(find tests/queries -type f -name '*.sql')
|
|
|
|
debug=0
|
|
|
|
if [ -n "${1:-""}" ]; then
|
|
|
|
find_cmd+=(-regex ".*$1.*")
|
|
|
|
debug=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
"${find_cmd[@]}" | sort > testcases.txt
|
|
|
|
|
|
|
|
if [ ! -s testcases.txt ]; then
|
|
|
|
echo "no matching testcases found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$(cat testcases.txt | wc -l)" == "1" ]; then
|
2018-03-10 18:25:13 +00:00
|
|
|
set -x
|
2018-03-10 16:54:36 +00:00
|
|
|
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
|
2018-03-05 02:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|