-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_all_scratch_tests.sh
executable file
·107 lines (67 loc) · 2.01 KB
/
run_all_scratch_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /bin/bash
ScriptPath=$0
Dir=$(cd $(dirname "$ScriptPath"); pwd)
Basename=$(basename "$ScriptPath")
CMakeDir=$Dir/_build
RunMake=1
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
case $1 in
-M|--no-make)
RunMake=0
;;
--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-2024, Matthew Wilson and Synesis Information Systems
Copyright (c) 2008-2019, Matthew Wilson and Synesis Software
Runs all (matching) scratch-test programs
$ScriptPath [ ... flags/options ... ]
Flags/options:
behaviour:
-M
--no-make
does not execute CMake and make before running tests
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()
status=0
if [ $RunMake -ne 0 ]; then
echo "Executing make and then running all test programs"
mkdir -p $CMakeDir || exit 1
cd $CMakeDir
make
status=$?
else
if [ ! -d "$CMakeDir" ] || [ ! -f "$CMakeDir/CMakeCache.txt" ] || [ ! -d "$CMakeDir/CMakeFiles" ]; then
>&2 echo "$ScriptPath: cannot run in '--no-make' mode without a previous successful build step"
else
echo "Running all test programs"
fi
cd $CMakeDir
fi
if [ $status -eq 0 ]; then
for f in $(find $Dir -type f '(' -name 'test_scratch*' -o -name 'test.scratch.*' -o -name 'test_performance*' -o -name 'test.performance.*' ')' -exec test -x {} \; -print)
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
fi
cd ->/dev/null
exit $status
# ############################## end of file ############################# #