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