Skip to content

Commit 981dc75

Browse files
committed
Unified test runner scripts and their output format
Eliminated nothing-to-stdout everything-to-log-file policy: info is printed to stdout and it is the caller's responsibility to redirect it to a file if needed. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent f4c48f4 commit 981dc75

File tree

4 files changed

+121
-118
lines changed

4 files changed

+121
-118
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ test-js.$(1).$(2): build-all.$$(NATIVE_SYSTEM)
315315
$$(Q) $$(call SHLOG,./tools/runners/run-precommit-check-for-target.sh \
316316
$$(OUT_DIR)/$(1)/jerry \
317317
$$(OUT_DIR)/$(1)/check/$(2) \
318-
$(3), $$(OUT_DIR)/$(1)/check/$(2)/jerry_test.log,Testing)
318+
$(3),$$(OUT_DIR)/$(1)/check/$(2)/jerry_test.log,Testing)
319319
endef
320320

321321
$(foreach __TARGET,$(JERRY_TEST_TARGETS), \
@@ -356,8 +356,7 @@ build: $(patsubst %,build-all.%,$(NATIVE_SYSTEM) $(foreach __SYSTEM,$(MCU_SYSTEM
356356
test-unit: unittests
357357
$(Q) rm -rf $(OUT_DIR)/unittests/check
358358
$(Q) mkdir -p $(OUT_DIR)/unittests/check
359-
$(Q) ./tools/runners/run-unittests.sh $(OUT_DIR)/unittests || \
360-
(echo "Unit tests run failed. See $(OUT_DIR)/unittests/unit_tests_run.log for details."; exit 1;)
359+
$(Q) $(call SHLOG,./tools/runners/run-unittests.sh $(OUT_DIR)/unittests,$(OUT_DIR)/unittests/unittests.log,Unit tests)
361360

362361
.PHONY: test-js
363362
test-js: $(foreach __TARGET,$(JERRY_TEST_TARGETS),test-js.$(__TARGET))

tools/runners/run-test-pass.sh

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Copyright 2014-2016 Samsung Electronics Co., Ltd.
4+
# Copyright 2016 University of Szeged
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
67
# you may not use this file except in compliance with the License.
@@ -16,80 +17,71 @@
1617

1718
TIMEOUT=${TIMEOUT:=5}
1819

19-
START_DIR=`pwd`
20-
21-
ENGINE=$START_DIR/$1
20+
ENGINE=$1
2221
shift
2322

2423
OUT_DIR=$1
2524
shift
2625

27-
TESTS=$START_DIR/$1
26+
TESTS=$1
2827
shift
2928

30-
ECHO_PROGRESS=1
31-
JERRY_ARGS=
32-
while (( "$#" ))
33-
do
34-
if [ "$1" = "--parse-only" ]
35-
then
36-
JERRY_ARGS="$JERRY_ARGS $1"
37-
fi
38-
if [ "$1" = "--output-to-log" ]
39-
then
40-
exec 1>$OUT_DIR/jerry_test.log
41-
ECHO_PROGRESS=0
42-
fi
43-
44-
shift
45-
done
29+
JERRY_ARGS="$@"
4630

4731
if [ ! -x $ENGINE ]
4832
then
49-
echo \"$ENGINE\" is not an executable file
33+
echo "\"$ENGINE\" is not an executable file"
34+
exit 1
5035
fi
5136

52-
cd $OUT_DIR
37+
if [ ! -d $OUT_DIR ]
38+
then
39+
mkdir -p $OUT_DIR
40+
fi
5341

54-
JS_FILES=js.files
55-
JERRY_ERROR=jerry.error
56-
JERRY_OK=jerry.passed
42+
JS_FILES=$OUT_DIR/js.files
43+
JERRY_ERROR=$OUT_DIR/jerry.error
44+
JERRY_OK=$OUT_DIR/jerry.passed
5745

58-
rm -f $JS_FILES $JERRY_ERROR
46+
rm -f $JS_FILES $JERRY_ERROR $JERRY_OK
5947

6048
if [ -d $TESTS ];
6149
then
6250
find $TESTS -path $TESTS/fail -prune -o -name "[^N]*.js" -print | sort > $JS_FILES
6351
else
6452
if [ -f $TESTS ];
6553
then
66-
awk "{print \"$START_DIR/\"\$1;}" $TESTS > $JS_FILES
54+
cp $TESTS $JS_FILES
55+
else
56+
exit 1
6757
fi;
6858
fi;
6959
total=$(cat $JS_FILES | wc -l)
7060

71-
tested=0
61+
if [ "$total" -eq 0 ]
62+
then
63+
echo "No test to execute"
64+
exit 1
65+
fi
66+
67+
tested=1
7268
failed=0
7369
passed=0
7470

75-
JERRY_TEMP=jerry.tmp
76-
77-
echo " Passed / Failed / Tested / Total / Percent"
71+
JERRY_TEMP=`mktemp`
7872

7973
for test in `cat $JS_FILES`
8074
do
81-
percent=$(echo $tested*100/$total | bc)
75+
echo -n "[${tested}/${total}] ${ENGINE} ${JERRY_ARGS} ${test}: "
8276

8377
( ulimit -t $TIMEOUT; ${ENGINE} ${JERRY_ARGS} ${test} &>$JERRY_TEMP; exit $? );
8478
status_code=$?
8579

86-
if [ $ECHO_PROGRESS -eq 1 ]
87-
then
88-
printf "\r\e[2K[ %6d / %6d / %6d / %5d / %3d%% ]" ${passed} ${failed} ${tested} ${total} ${percent}
89-
fi
90-
9180
if [ $status_code -ne 0 ]
9281
then
82+
echo "FAIL ($status_code)"
83+
cat $JERRY_TEMP
84+
9385
echo "$status_code: ${test}" >> $JERRY_ERROR
9486
echo "============================================" >> $JERRY_ERROR
9587
cat $JERRY_TEMP >> $JERRY_ERROR
@@ -99,7 +91,10 @@ do
9991

10092
failed=$((failed+1))
10193
else
94+
echo "PASS"
95+
10296
echo "${test}" >> $JERRY_OK
97+
10398
passed=$((passed+1))
10499
fi
105100

@@ -108,16 +103,9 @@ done
108103

109104
rm -f $JERRY_TEMP
110105

111-
printf "\r\e[2K[ %6d / %6d / %6d / %5d / %3d%% ]\n" ${passed} ${failed} ${tested} ${total} ${percent}
112-
113106
ratio=$(echo $passed*100/$total | bc)
114107

115-
echo ==========================
116-
echo "Number of tests passed: ${passed}"
117-
echo "Number of tests failed: ${failed}"
118-
echo --------------------------
119-
echo "Total number of tests: ${total}"
120-
echo "Passed: ${ratio}%"
108+
echo "[summary] ${ENGINE} ${JERRY_ARGS} ${TESTS}: ${passed} PASS, ${failed} FAIL, ${total} total, ${ratio}% success"
121109

122110
if [ ${failed} -ne 0 ]
123111
then

tools/runners/run-test-xfail.sh

Lines changed: 29 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
# Copyright 2014-2015 Samsung Electronics Co., Ltd.
3+
# Copyright 2014-2016 Samsung Electronics Co., Ltd.
4+
# Copyright 2016 University of Szeged
45
#
56
# Licensed under the Apache License, Version 2.0 (the "License");
67
# you may not use this file except in compliance with the License.
@@ -16,9 +17,7 @@
1617

1718
TIMEOUT=${TIMEOUT:=30}
1819

19-
START_DIR=`pwd`
20-
21-
ENGINE=$START_DIR/$1
20+
ENGINE=$1
2221
shift
2322

2423
OUT_DIR=$1
@@ -27,41 +26,27 @@ shift
2726
ERROR_CODE=$1
2827
shift
2928

30-
TESTS=$START_DIR/$1/fail/$ERROR_CODE
29+
TESTS=$1/fail/$ERROR_CODE
3130
shift
3231

33-
ECHO_PROGRESS=1
34-
JERRY_ARGS=
35-
while (( "$#" ))
36-
do
37-
if [ "$1" = "--parse-only" ]
38-
then
39-
JERRY_ARGS="$JERRY_ARGS $1"
40-
fi
41-
if [ "$1" = "--output-to-log" ]
42-
then
43-
exec 1>$OUT_DIR/jerry_test.log
44-
ECHO_PROGRESS=0
45-
fi
46-
shift
47-
done
32+
JERRY_ARGS="$@"
4833

4934
if [ ! -x $ENGINE ]
5035
then
51-
echo \"$ENGINE\" is not an executable file
36+
echo "\"$ENGINE\" is not an executable file"
37+
exit 1
5238
fi
5339

5440
if [ ! -d $OUT_DIR ]
5541
then
5642
mkdir -p $OUT_DIR
5743
fi
58-
cd $OUT_DIR
5944

60-
JS_FILES=js.fail.files
61-
JERRY_ERROR=jerry.error
62-
JERRY_OK=jerry.passed
45+
JS_FILES=$OUT_DIR/js.fail.files
46+
JERRY_ERROR=$OUT_DIR/jerry.error
47+
JERRY_OK=$OUT_DIR/jerry.passed
6348

64-
rm -f $JS_FILES $JERRY_ERROR
49+
rm -f $JS_FILES $JERRY_ERROR $JERRY_OK
6550

6651
if [ -d $TESTS ];
6752
then
@@ -76,28 +61,30 @@ else
7661
fi;
7762
total=$(cat $JS_FILES | wc -l)
7863

79-
tested=0
64+
if [ "$total" -eq 0 ]
65+
then
66+
echo "No test to execute"
67+
exit 1
68+
fi
69+
70+
tested=1
8071
failed=0
8172
passed=0
8273

83-
JERRY_TEMP=jerry.tmp
84-
85-
echo " Passed / Failed / Tested / Total / Percent"
74+
JERRY_TEMP=`mktemp`
8675

8776
for test in `cat $JS_FILES`
8877
do
89-
percent=$(echo $tested*100/$total | bc)
78+
echo -n "[${tested}/${total}] ${ENGINE} ${JERRY_ARGS} ${test}: "
9079

91-
( ulimit -t $TIMEOUT; ${ENGINE} ${test} ${JERRY_ARGS} >&$JERRY_TEMP; exit $? );
80+
( ulimit -t $TIMEOUT; ${ENGINE} ${JERRY_ARGS} ${test} &>$JERRY_TEMP; exit $? );
9281
status_code=$?
9382

94-
if [ $ECHO_PROGRESS -eq 1 ]
95-
then
96-
printf "\r\e[2K[ %6d / %6d / %6d / %5d / %3d%% ]" ${passed} ${failed} ${tested} ${total} ${percent}
97-
fi
98-
9983
if [ $status_code -ne $ERROR_CODE ]
10084
then
85+
echo "FAIL ($status_code)"
86+
cat $JERRY_TEMP
87+
10188
echo "$status_code: ${test}" >> $JERRY_ERROR
10289
echo "============================================" >> $JERRY_ERROR
10390
cat $JERRY_TEMP >> $JERRY_ERROR
@@ -107,25 +94,21 @@ do
10794

10895
failed=$((failed+1))
10996
else
97+
echo "XFAIL"
98+
11099
echo "${test}" >> $JERRY_OK
100+
111101
passed=$((passed+1))
112102
fi
113103

114104
tested=$((tested+1))
115105
done
116106

117-
rm $JERRY_TEMP
118-
119-
printf "\r\e[2K[ %6d / %6d / %6d / %5d / %3d%% ]\n" ${passed} ${failed} ${tested} ${total} ${percent}
107+
rm -f $JERRY_TEMP
120108

121109
ratio=$(echo $passed*100/$total | bc)
122110

123-
echo ==========================
124-
echo "Number of tests passed: ${passed}"
125-
echo "Number of tests failed: ${failed}"
126-
echo --------------------------
127-
echo "Total number of tests: ${total}"
128-
echo "Passed: ${ratio}%"
111+
echo "[summary] ${ENGINE} ${JERRY_ARGS} ${TESTS}: ${passed} XFAIL, ${failed} FAIL, ${total} total, ${ratio}% success"
129112

130113
if [ ${failed} -ne 0 ]
131114
then

0 commit comments

Comments
 (0)