-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.sh
More file actions
73 lines (63 loc) · 1.83 KB
/
tests.sh
File metadata and controls
73 lines (63 loc) · 1.83 KB
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
#!/bin/bash
set -e
info() {
echo -e "\e[32m$1\e[0m"
}
usage() {
echo "usage: tests.sh [-l|--loop] [--debug] [-h|--help]"
}
prepare() {
if [ ! -f tests/catch.hpp ]; then
info "Downloading Catch2..."
wget -O tests/catch.hpp https://github.com/catchorg/Catch2/releases/download/v2.11.0/catch.hpp
echo "c3e164751617483c25d42f7f71254d5e5ba39f6b4245c2cfd6cc7ea8d3918cad tests/catch.hpp" | sha256sum -c
fi
info "Compiling Catch2..."
mkdir -p build
g++ -std=gnu++11 tests/tests.cpp -c -o build/tests.o
}
run() {
info "Building tests..."
mkdir -p build
# Arduino IDE's arguments would be like:
#-g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto
readarray -t testfiles < <(cat testindex.txt | grep -v -e '^[[:space:]]*$' | grep -v -e '^[[:space:]]*#')
g++ -std=gnu++11\
-o build/run-tests \
-Ilibscheduling/src \
build/tests.o "${testfiles[@]}"
if [ "$?" == "0" ]; then
info "Running tests..."
./build/run-tests
else
info "Error building the tests :("
fi
}
do_loop=0
while [ "$1" != "" ]; do
case $1 in
-l | --loop ) do_loop=1
;;
--debug ) set -x
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
prepare
if [ "$do_loop" == "1" ]; then
set +e
while true
do
run
echo "Press [Enter] to re-run the tests or input 'q' to exit."
read line
if [ "$line" == "q" ] || [ "$line" == "quit" ] || [ "$line" == "exit" ]; then break; fi
done
else
run
fi