Commit af2dbce0 authored by User expired's avatar User expired
Browse files

test: Allow test selection with wildcard and regex

parent 0f440475
......@@ -35,6 +35,14 @@ Install scripts to `$HOME/bin`:
make install
Run all or selected tests:
make test # all tests
./test/test_runner pattern...
With one or more filter patterns containing the wildcard `*`. Otherwise,
usual regular expressions are supported, for example `testJournal[UD]*`.
Remove scripts from `$HOME/bin`:
make uninstall
#! /bin/bash
# Unit test suite runner.
# Usage: test_runner [filter...]
# Filter: One or several patterns to exactly match test names. The pattern may
# contain "*" as a wildcard and otherwise the usual regular expressions.
EXIT_CODE=0
if [ $# -gt 0 ]
then
grep -o '^test[^( ]*()' $(dirname $0)/* \
| sed 's/()$//' \
| egrep "($(sed 's/ */|/g;s/\./\\./g;s/\*/.*/g' <<< "${@}"))$" \
| awk -F: '{
if ($1 != lastfile) {
printf("\necho; ");
printf("\necho --- Executing selected tests from »%s«. ---; ", $1);
printf("%s -- %s", $1, $2);
} else {
printf(" %s", $2);
}
lastfile=$1
}
END { printf("\n") }' \
| sed 1d \
| sh
else
EXIT_CODE=0
for test in $(dirname $0)/*_test
do
echo
echo "--- Executing the '$(basename ${test%_test})' test suite. ---"
$test || EXIT_CODE=1
done
for test in $(dirname $0)/*_test
do
echo
echo "--- Executing the '$(basename ${test%_test})' test suite. ---"
$test || EXIT_CODE=1
done
exit $EXIT_CODE
exit $EXIT_CODE
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment