annotate tests/run-tests.sh @ 10:0feba0fea9d0

Allow local makefile overrides in local.mk
author Guido Berhoerster <guido+libpws@berhoerster.name>
date Wed, 31 Jul 2019 11:21:50 +0200
parents dfd3ddbdb201
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
1 #!/bin/sh
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
2 #
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
3 # Copyright (C) 2016 Guido Berhoerster <guido+libpws@berhoerster.name>
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
4 #
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
5 # Permission is hereby granted, free of charge, to any person obtaining
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
6 # a copy of this software and associated documentation files (the
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
7 # "Software"), to deal in the Software without restriction, including
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
8 # without limitation the rights to use, copy, modify, merge, publish,
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
9 # distribute, sublicense, and/or sell copies of the Software, and to
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
10 # permit persons to whom the Software is furnished to do so, subject to
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
11 # the following conditions:
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
12 #
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
13 # The above copyright notice and this permission notice shall be included
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
14 # in all copies or substantial portions of the Software.
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
15 #
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
17 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
18 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
19 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
20 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
21 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
22 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
23 #
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
24
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
25 export PWSDUMP="${PWSDUMP:-pwsdump}"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
26
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
27 export LC_ALL=C
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
28 export TESTS_PATH="$(dirname "$0")"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
29 export TESTS_OUTPUT_PATH="${TESTS_OUTPUT_PATH:-${TESTS_PATH}/output}"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
30
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
31 tests_passed=0
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
32 tests_failed=0
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
33
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
34 mkdir -p "${TESTS_OUTPUT_PATH}" || exit 1
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
35
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
36 for t in "${TESTS_PATH}"/test-*.sh; do
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
37 [ -r "${t}" ] || break
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
38
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
39 export LOGFILE="${TESTS_OUTPUT_PATH}/$(basename "${t}").log"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
40
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
41 [ -t 1 ] && printf "Running %s" "${t}"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
42 if ${SHELL:-/bin/sh} "$t" >/dev/null 2>"${LOGFILE}"; then
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
43 tests_passed=$(( tests_passed + 1 ))
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
44 if [ -t 1 ]; then
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
45 printf "\rOK "
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
46 else
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
47 printf "OK %s" "${t}"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
48 fi
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
49 else
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
50 tests_failed=$(( tests_failed + 1 ))
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
51 if [ -t 1 ]; then
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
52 printf "\rFAILED "
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
53 else
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
54 printf "FAILED %s" "${t}"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
55 fi
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
56 fi
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
57 printf "%s\n" "${t}"
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
58 done
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
59
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
60 printf -- "-----------\npassed: %3d\nfailed: %3d\ntotal: %3d\n" $tests_passed \
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
61 $tests_failed $(( tests_failed + tests_passed ))
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
62
dfd3ddbdb201 Add tests
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff changeset
63 [ $tests_failed -eq 0 ]