/
run_all_unit_tests.sh
executable file
·81 lines (51 loc) · 1.51 KB
/
run_all_unit_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/bash
ScriptPath=$0
Dir=$(cd $(dirname "$ScriptPath"); pwd)
Basename=$(basename "$ScriptPath")
CMakePath=$Dir/_build
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
case $1 in
--help)
cat << EOF
xTests is a small, lightweight, portable, simple unit- and component-test framework suitable for exercising C and C++ libraries
Copyright (c) 2019-2023, Matthew Wilson and Synesis Information Systems
Copyright (c) 2008-2019, Matthew Wilson and Synesis Software
Runs all (matching) unit-test programs
$ScriptPath [ ... flags/options ... ]
Flags/options:
behaviour:
standard flags:
--help
displays this help and terminates
EOF
exit 0
;;
*)
>&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage"
exit 1
;;
esac
shift
done
# ##########################################################
# main()
mkdir -p $CMakePath || exit 1
cd $CMakePath
echo "Executing make and then running all test programs"
status=0
if make; then
for f in $(find $Dir -type f -perm +111 '(' -name 'test_*' -o -name 'test.*' ')')
do
echo
echo "executing $f:"
# NOTE: we do not break on fail, because, this being a unit-testing library, the scratch-tests actually fail
$f
done
else
status=$?
fi
cd ->/dev/null
exit $status
# ############################## end of file ############################# #