File tree Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Expand file tree Collapse file tree 1 file changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,47 @@ if [ "$INPUT" = "-h" ] || [ "$#" -gt 1 ]; then
33
33
exit 1
34
34
fi
35
35
36
+ if [ -t 1 ]; then
37
+ GREEN=' \033[0;32m'
38
+ RED=' \033[0;31m'
39
+ RESET=' \033[0m'
40
+ else
41
+ GREEN=" "
42
+ RED=" "
43
+ RESET=" "
44
+ fi
45
+
46
+ WITH_TIMEOUT=" "
47
+ if [ -x " $( command -v timeout) " ]; then
48
+ WITH_TIMEOUT=" timeout -s KILL 5s"
49
+ elif [ -x " $( command -v gtimeout) " ]; then # MacOS from `brew install coreutils`
50
+ WITH_TIMEOUT=" gtimeout -s KILL 5s"
51
+ else
52
+ echo " $0 : timeout command not available, tests may run indefinitely long." 1>&2
53
+ fi
54
+
36
55
for impl in $( ls calculate_average_* .sh | sort) ; do
37
56
noext=" ${impl%% .sh} "
38
57
fork=${noext## calculate_average_}
39
58
40
- if output=$( ./test.sh " $fork " " $INPUT " 2>&1 ) ; then
41
- echo " PASS $fork "
59
+ # ./test.sh calls ./prepare_$fork.sh e.g. to build native image
60
+ # which may take some time.
61
+ # Here we run it upfront, assuming that prepare result is cached
62
+ # to avoid timeout due to long preparation.
63
+ if [ -f " ./prepare_$fork .sh" ]; then
64
+ if ! output=$( " ./prepare_$fork .sh" 2>&1 ) ; then
65
+ echo " $output " 1>&2
66
+ echo " FAIL $fork "
67
+ continue
68
+ fi
69
+ fi
70
+
71
+ if output=$( $WITH_TIMEOUT ./test.sh " $fork " " $INPUT " 2>&1 ) ; then
72
+ echo -e " ${GREEN} PASS${RESET} $fork "
73
+ elif [ $? -eq 137 ]; then
74
+ echo -e " ${RED} TIME${RESET} $fork "
42
75
else
43
- echo " FAIL $fork "
44
76
echo " $output " 1>&2
77
+ echo -e " ${RED} FAIL${RESET} $fork "
45
78
fi
46
79
done
You can’t perform that action at this time.
0 commit comments