Skip to content

Commit 6761d78

Browse files
AlexanderYastrebovgunnarmorling
authored andcommitted
test_all.sh: configure fork test timeout
Example output: ``` $ ./test_all.sh 2>/dev/null PASS abfrmblr PASS AbstractKamen PASS ags313 PASS alesj PASS algirdasrascius PASS anandmattikopp PASS arjenvaneerde FAIL armandino TIME artpar PASS artsiomkorzun PASS asun PASS baseline PASS berry120 PASS bjhara PASS charlibot PASS coolmineman PASS couragelee PASS criccomini PASS davecom PASS davery22 PASS ddimtirov PASS deemkeen PASS ebarlas PASS entangled90 FAIL fatroom PASS felix19350 PASS filiphr PASS flippingbits PASS fragmede PASS gabrielreid PASS gamlerhart PASS gnmathur PASS hchiorean FAIL hundredwatt PASS imrafaelmerino PASS isolgpus PASS itaske PASS iziamos PASS japplis PASS jgrateron PASS jotschi PASS kevinmcmurtrie PASS kgeri PASS khmarbaise PASS kuduwa-keshavram PASS kumarsaurav123 FAIL lawrey PASS maeda6uiui PASS MeanderingProgrammer PASS merykitty FAIL moysesb PASS mudit-saxena PASS obourgain PASS padreati PASS palmr PASS pedestrianlove PASS phd3 PASS raipc PASS rby PASS richardstartin FAIL roman-r-m PASS royvanrijn PASS rprabhu PASS santanu PASS seijikun PASS semotpan PASS spullara PASS thomaswue PASS truelive FAIL twobiers PASS Ujjwalbharti PASS yavuztas PASS yehwankim23 FAIL yemreinci PASS zerninv ```
1 parent 3144c9c commit 6761d78

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

test_all.sh

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,47 @@ if [ "$INPUT" = "-h" ] || [ "$#" -gt 1 ]; then
3333
exit 1
3434
fi
3535

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+
3655
for impl in $(ls calculate_average_*.sh | sort); do
3756
noext="${impl%%.sh}"
3857
fork=${noext##calculate_average_}
3958

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"
4275
else
43-
echo "FAIL $fork"
4476
echo "$output" 1>&2
77+
echo -e "${RED}FAIL${RESET} $fork"
4578
fi
4679
done

0 commit comments

Comments
 (0)