Skip to content

Commit 1c94e8b

Browse files
committed
Improve the usability of test runner scripts
* First of all, remove the counter-intuitive "OUT_DIR" second argument of run-test-suite.sh. This, way, the invocation of the script becomes easier to remember: `tools/runners/run-test-suite.sh <engine> <testsuite>` However, this also means that all output files (lists of executed, passed, and failed tests) are generated in the current working directory. * Align the behaviour of run-unittests.sh with the above, i.e., don't try to guess where to put output files but write them in the CWD. * Adapt Makefile to the change in the use of the test runner scripts: create and change to "check" directories before invoking test runner scripts. Extras: * tools/runners/run-test-suite.sh collected fail tests from directories twice. This does no harm but is inefficient, thus removing. * tools/runners/run-test-suite.sh was too permissive on the contents of test suite list files. Better to accept those lines only which really contain paths to JS test files. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent a0bedaa commit 1c94e8b

File tree

3 files changed

+26
-39
lines changed

3 files changed

+26
-39
lines changed

Makefile

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ export NATIVE_MODS := $(MCU_MODS) mem_stats mem_stress_test
105105
# Compiler to use for external build
106106
EXTERNAL_C_COMPILER ?= arm-none-eabi-gcc
107107

108+
# Directories
109+
export ROOT_DIR := $(shell pwd)
110+
export BUILD_DIR_PREFIX := $(ROOT_DIR)/build/obj
111+
export BUILD_DIR := $(BUILD_DIR_PREFIX)-VALGRIND-$(VALGRIND)-VALGRIND_FREYA-$(VALGRIND_FREYA)-LTO-$(LTO)-ALL_IN_ONE-$(ALL_IN_ONE)
112+
export OUT_DIR := $(ROOT_DIR)/build/bin
113+
export PREREQUISITES_STATE_DIR := $(ROOT_DIR)/build/prerequisites
114+
115+
SHELL := /bin/bash
116+
108117
# Build targets
109118
export JERRY_NATIVE_TARGETS := \
110119
$(foreach __MODE,$(DEBUG_MODES) $(RELEASE_MODES), \
@@ -132,18 +141,10 @@ export JERRY_TEST_TARGETS_CP := \
132141
$(__MODE).$(NATIVE_SYSTEM)-cp)
133142

134143
# JS test suites (in the format of id:path)
135-
export JERRY_TEST_SUITE_J := j:./tests/jerry
136-
export JERRY_TEST_SUITE_JTS := jts:./tests/jerry-test-suite
137-
export JERRY_TEST_SUITE_JTS_PREC := jts-prec:./tests/jerry-test-suite/precommit-test-list
138-
export JERRY_TEST_SUITE_JTS_CP := jts-cp:./tests/jerry-test-suite/compact-profile-list
139-
140-
# Directories
141-
export BUILD_DIR_PREFIX := ./build/obj
142-
export BUILD_DIR := $(BUILD_DIR_PREFIX)-VALGRIND-$(VALGRIND)-VALGRIND_FREYA-$(VALGRIND_FREYA)-LTO-$(LTO)-ALL_IN_ONE-$(ALL_IN_ONE)
143-
export OUT_DIR := ./build/bin
144-
export PREREQUISITES_STATE_DIR := ./build/prerequisites
145-
146-
SHELL := /bin/bash
144+
export JERRY_TEST_SUITE_J := j:$(ROOT_DIR)/tests/jerry
145+
export JERRY_TEST_SUITE_JTS := jts:$(ROOT_DIR)/tests/jerry-test-suite
146+
export JERRY_TEST_SUITE_JTS_PREC := jts-prec:$(ROOT_DIR)/tests/jerry-test-suite/precommit-test-list
147+
export JERRY_TEST_SUITE_JTS_CP := jts-cp:$(ROOT_DIR)/tests/jerry-test-suite/compact-profile-list
147148

148149
# Default make target
149150
.PHONY: all
@@ -235,7 +236,7 @@ $(1)/Makefile: $(1)/toolchain.config
235236
-DENABLE_LTO=$$(LTO) \
236237
-DENABLE_ALL_IN_ONE=$$(ALL_IN_ONE) \
237238
-DUSE_COMPILER_DEFAULT_LIBC=$$(USE_COMPILER_DEFAULT_LIBC) \
238-
-DCMAKE_TOOLCHAIN_FILE=`cat toolchain.config` ../../.. 2>&1),$(1)/cmake.log,CMake run)
239+
-DCMAKE_TOOLCHAIN_FILE=`cat toolchain.config` $$(ROOT_DIR) 2>&1),$(1)/cmake.log,CMake run)
239240
endef
240241

241242
$(foreach __SYSTEM,$(NATIVE_SYSTEM) $(MCU_SYSTEMS), \
@@ -295,9 +296,9 @@ $(eval $(call BUILD_RULE,unittests,$(NATIVE_SYSTEM),unittests))
295296
# its non-deterministically vanishing .a files.
296297
define JSTEST_RULE
297298
test-js.$(1).$(2): build.$$(NATIVE_SYSTEM)
298-
$$(Q) $$(call SHLOG,./tools/runners/run-test-suite.sh \
299+
$$(Q) mkdir -p $$(OUT_DIR)/$(1)/check/$(2)
300+
$$(Q) $$(call SHLOG,cd $$(OUT_DIR)/$(1)/check/$(2) && $$(ROOT_DIR)/tools/runners/run-test-suite.sh \
299301
$$(OUT_DIR)/$(1)/jerry \
300-
$$(OUT_DIR)/$(1)/check/$(2) \
301302
$(3),$$(OUT_DIR)/$(1)/check/$(2)/test.log,Testing)
302303
endef
303304

@@ -332,7 +333,8 @@ build: build.$(NATIVE_SYSTEM) $(foreach __SYSTEM,$(MCU_SYSTEMS),build.mcu_$(__SY
332333

333334
.PHONY: test-unit
334335
test-unit: unittests
335-
$(Q) $(call SHLOG,./tools/runners/run-unittests.sh $(OUT_DIR)/unittests,$(OUT_DIR)/unittests/check/unittests.log,Unit tests)
336+
$(Q) mkdir -p $(OUT_DIR)/unittests/check
337+
$(Q) $(call SHLOG,cd $(OUT_DIR)/unittests/check && $(ROOT_DIR)/tools/runners/run-unittests.sh $(OUT_DIR)/unittests,$(OUT_DIR)/unittests/check/unittests.log,Unit tests)
336338

337339
.PHONY: test-js
338340
test-js: \

tools/runners/run-test-suite.sh

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ TIMEOUT=${TIMEOUT:=5}
2020
ENGINE="$1"
2121
shift
2222

23-
OUT_DIR="$1"
24-
shift
25-
2623
TESTS="$1"
2724
shift
2825

@@ -34,30 +31,20 @@ then
3431
exit 1
3532
fi
3633

37-
mkdir -p $OUT_DIR
38-
39-
TEST_FILES=$OUT_DIR/test.files
40-
TEST_FAILED=$OUT_DIR/test.failed
41-
TEST_PASSED=$OUT_DIR/test.passed
34+
TEST_FILES=test.files
35+
TEST_FAILED=test.failed
36+
TEST_PASSED=test.passed
4237

4338
if [ -d $TESTS ]
4439
then
4540
TESTS_DIR=$TESTS
4641

47-
( cd $TESTS; find . -path fail -prune -o -name "[^N]*.js" -print ) | sort > $TEST_FILES
48-
49-
if [ -d $TESTS/fail ]
50-
then
51-
for error_code in `cd $TESTS/fail && ls -d [0-9]*`
52-
do
53-
( cd $TESTS; find ./fail/$error_code -name "[^N]*.js" -print ) | sort >> $TEST_FILES
54-
done
55-
fi
42+
( cd $TESTS; find . -name "[^N]*.js" ) | sort > $TEST_FILES
5643
elif [ -f $TESTS ]
5744
then
5845
TESTS_DIR=`dirname $TESTS`
5946

60-
cp $TESTS $TEST_FILES
47+
grep -e '.js\s*$' $TESTS | sort > $TEST_FILES
6148
else
6249
echo "$0: $TESTS: not a test suite"
6350
exit 1
@@ -93,7 +80,7 @@ do
9380

9481
echo -n "[$tested/$total] $ENGINE $ENGINE_ARGS $full_test: "
9582

96-
( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS $full_test &>$ENGINE_TEMP; exit $? )
83+
( ulimit -t $TIMEOUT; $ENGINE $ENGINE_ARGS $full_test &>$ENGINE_TEMP )
9784
status_code=$?
9885

9986
if [ $status_code -ne $error_code ]

tools/runners/run-unittests.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
DIR="$1"
1919
shift
2020

21-
mkdir -p $DIR/check
22-
23-
UNITTEST_ERROR=$DIR/check/unittests.failed
24-
UNITTEST_OK=$DIR/check/unittests.passed
21+
UNITTEST_ERROR=unittests.failed
22+
UNITTEST_OK=unittests.passed
2523

2624
rm -f $UNITTEST_ERROR $UNITTEST_OK
2725

0 commit comments

Comments
 (0)