annotate tests/run-tests.sh @ 41:0af8d2d8cd1a

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