test-queries: can debug a testcase
`tests/test-queries regex` filters the test cases. If the resulting set has only one test case, run it under gdb.
This commit is contained in:
parent
210f322a1c
commit
b7c134efc0
|
@ -42,3 +42,6 @@
|
||||||
/testcase-out.txt
|
/testcase-out.txt
|
||||||
/testcase-stdout.txt
|
/testcase-stdout.txt
|
||||||
/testcase-stderr.txt
|
/testcase-stderr.txt
|
||||||
|
/testcase-expected.txt
|
||||||
|
/testcase-cmds.txt
|
||||||
|
/testcases.txt
|
||||||
|
|
|
@ -24,18 +24,36 @@ main() {
|
||||||
root=$(readlink -f "$root")
|
root=$(readlink -f "$root")
|
||||||
cd "$root"
|
cd "$root"
|
||||||
|
|
||||||
queries=$(find tests/queries -type f -name '*.sql' | sort)
|
find_cmd=(find tests/queries -type f -name '*.sql')
|
||||||
while read -r file; do
|
debug=0
|
||||||
echo "Testing: $file"
|
if [ -n "${1:-""}" ]; then
|
||||||
query=$(head -n1 "$file" | tail -n1)
|
find_cmd+=(-regex ".*$1.*")
|
||||||
results=$(tail -n+2 "$file")
|
debug=1
|
||||||
if ! "$root"/sqlite/sqlite3 -init <(run_query "$file" "$query") < /dev/null > testcase-stdout.txt 2> testcase-stderr.txt; then
|
fi
|
||||||
echo "...FAILED; check testcase-{out,err}.txt" >&2
|
|
||||||
|
"${find_cmd[@]}" | sort > testcases.txt
|
||||||
|
|
||||||
|
if [ ! -s testcases.txt ]; then
|
||||||
|
echo "no matching testcases found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
diff testcase-out.txt <(echo "$results")
|
if [ "$(cat testcases.txt | wc -l)" == "1" ]; then
|
||||||
done < <(echo "$queries")
|
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 "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue