/ devlog / devscripts / check_run_output.sh
#!/bin/sh
# Reads the whole of what a run printed and refuses it where anything in
# it says something went wrong. Written because a run was reported as
# passing on a count of its passing lines while twenty-one failed SQL
# statements stood in the same output, and because the fix that followed
# counted only the phrase seen that day.
#
#   sh devlog/devscripts/check_run_output.sh <file-a-run-printed>
#
# What counts as wrong is anything PHP says went wrong, anything a
# database says it could not do, and the words the test runner and the
# daemons use when they fail. A line that merely names one of these
# words while reporting a case, such as a case with "error" in its name,
# is left alone: only lines that read as a report of trouble count.
said="$1"
if [ ! -f "$said" ]; then
    echo "check_run_output: FAIL nothing to read at $said"
    exit 1
fi
words='Fatal error|Parse error|Uncaught|PHP Warning|PHP Notice'
words="$words|PHP Deprecated|Warning:|Notice:|Deprecated:"
words="$words|Exec failed|no such table|no such column|SQLSTATE"
words="$words|Undefined variable|Undefined array key|Undefined index"
words="$words|Undefined property|Undefined method|Call to a member"
words="$words|failed to open stream|Permission denied|Segmentation"
found=`grep -c -E "$words" "$said"`
if [ "$found" -gt 0 ]; then
    echo "check_run_output: FAIL $found line(s) in $said say something"
    echo "  went wrong. The first few:"
    grep -n -E "$words" "$said" | head -5 | sed 's/^/    /' |
        cut -c1-76
    exit 1
fi
echo "check_run_output: PASS nothing in $said says it went wrong"
exit 0
X