#!/bin/sh

# The point of this script is to exit with errorneous exit code
# if grep finds any errors in the test output.
#
# Script output is machine-readable wrt exit code and there is
# also human-readable test result to make it explicit.
#
# Input might be a failed SQL query with a text marker "FAILED"
# or it might be some SQLite3 error in stderr (e.g. "no such colaltion")
#
# Note that stderr should be redirected to stdin outside of this script (2>&1).

# grep will print the lines it finds (if any) so they can be inspected
grep -i -e "FAILED" -e "ERROR"

if [ $? -eq 0 ]; then
    echo "++ some sqlite3 extension tests failed (above)"
    exit 1
fi

echo "++ all sqlite3 extension tests passed"
exit 0
