fostr/bin/run_tests
Glen Whitney 7feddbcfbe
All checks were successful
continuous-integration/drone/push Build is passing
Extraction from streams (#25)
Add the ! postfix operator and !! expression.
  Also add the ++ string concatenation operator.
  Also allow specification of standard input in the test scheme.

  Resolves #7, #18.

Co-authored-by: Glen Whitney <glen@studioinfinity.org>
Reviewed-on: #25
Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net>
Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
2021-03-13 19:30:23 +00:00

40 lines
831 B
Bash
Executable File

#!/bin/bash
command=$1
ext=$2
total=0
failed=0
diffed=0
for dir in tests/extracted/*; do
for file in $dir/*.$ext; do
((total++))
if [[ -f ${file%.*}.in ]]; then
cat ${file%.*}.in | $command $file > $file.out
result=$?
else
$command $file > $file.out
result=$?
fi
if [[ $result -ne 0 ]]; then
echo ERROR: $command $file failed.
((failed++))
else
if [[ -f ${file%.*}.expect ]]; then
echo ---- diff ${file%.*}.expect $file.out ----
diff ${file%.*}.expect $file.out
if [[ $? -ne 0 ]]; then
((diffed++))
fi
echo -------------------------------
fi
fi
done
done
echo "Ran $total tests: $failed failures, $diffed runs differed."
if [[ $failed -gt 0 ]] || [[ $diffed -gt 0 ]]; then
exit 1
fi
exit 0