Skip to content

Commit 293e706

Browse files
committed
Refactor JavaScript test recipes
Refactor JavaScript test recipes to loop over individual test files, rather than run all tests at the same time. This prevents the process from crashing due to OUT_OF_MEMORY errors. Additionally, the test commands will exit early upon first encountering a failing test, thus hopefully making finding failing tests easier as compared to running all tests in bulk. Further, we only set NODE_ENV=test when running tests and set the NODE_ENV environment variable to other values depending on the command invoked.
1 parent 7c8a09e commit 293e706

File tree

8 files changed

+45
-19
lines changed

8 files changed

+45
-19
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
# VARIABLES #
33

44
# Define the Node environment:
5-
NODE_ENV ?= test
5+
NODE_ENV ?=
6+
7+
# Define the Node path:
8+
NODE_PATH ?=
69

710
# Define whether the make commands are running on a hosted continuous integration service:
811
ifeq ($(TRAVIS), true)

tools/make/lib/benchmark/javascript.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# Define the command for `node`:
55
NODE ?= node
66

7+
# Define the Node environment:
8+
NODE_ENV ?= benchmark
9+
710

811
# TARGETS #
912

tools/make/lib/repl/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
# VARIABLES #
33

4+
# Define the Node environment:
5+
NODE_ENV ?= repl
6+
47
# Define the path of the REPL executable:
58
REPL ?= $(LOCAL_BIN_DIR)/repl
69

tools/make/lib/test-browsers/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22
# VARIABLES #
33

4+
# Define the Node environment:
5+
NODE_ENV ?= test
6+
7+
# Define the browser test runner:
48
BROWSER_TEST_RUNNER ?= testling
59

610
# Define the path to the browserify executable:
@@ -40,8 +44,6 @@ endif
4044
# [3]: https://github.com/scottcorgan/tap-spec
4145

4246
test-browsers: $(NODE_MODULES)
43-
NODE_ENV=$(NODE_ENV) \
44-
NODE_PATH=$(NODE_PATH_TEST) \
4547
$(BROWSERIFY) \
4648
$(BROWSERIFY_FLAGS) \
4749
$(TESTS) \

tools/make/lib/test-browsers/testling.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
# VARIABLES #
33

4+
# Define the Node environment:
5+
NODE_ENV ?= test
6+
47
# Determine the host kernel:
58
KERNEL ?= $(shell uname -s)
69

@@ -34,8 +37,6 @@ BROWSER_TEST_FLAGS ?=
3437
# [1]: https://github.com/substack/testling
3538

3639
view-testling: $(NODE_MODULES)
37-
NODE_ENV=$(NODE_ENV) \
38-
NODE_PATH=$(NODE_PATH_TEST) \
3940
$(BROWSERIFY) \
4041
$(BROWSERIFY_FLAGS) \
4142
$(TESTS) \

tools/make/lib/test-cov/istanbul.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ JAVASCRIPT_TEST_COV_FLAGS ?= --no-default-excludes \
4444
# [1]: https://github.com/gotwarlost/istanbul
4545

4646
test-istanbul: $(NODE_MODULES)
47-
NODE_ENV=$(NODE_ENV) \
48-
NODE_PATH=$(NODE_PATH_TEST) \
4947
$(JAVASCRIPT_TEST_COV) $(JAVASCRIPT_TEST_COV_FLAGS) $(JAVASCRIPT_TEST) -- $(JAVASCRIPT_TEST_FLAGS) $(TESTS)
5048

5149
.PHONY: test-istanbul

tools/make/lib/test-cov/javascript.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

22
# VARIABLES #
33

4+
# Define the Node environment:
5+
NODE_ENV ?= test
6+
7+
# Define the Node path:
8+
NODE_PATH ?= $(NODE_PATH_TEST)
9+
410
# Define the code coverage instrumentation utility:
511
JAVASCRIPT_CODE_INSTRUMENTER ?= istanbul
612

tools/make/lib/test/javascript.mk

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

22
# VARIABLES #
33

4+
# Define the Node environment:
5+
NODE_ENV ?= test
6+
7+
# Define the Node path:
8+
NODE_PATH ?= $(NODE_PATH_TEST)
9+
410
# Define the test runner to use when running JavaScript tests:
511
JAVASCRIPT_TEST_RUNNER ?= tape
612

@@ -33,12 +39,14 @@ test-javascript: test-javascript-local
3339
# This target runs JavaScript unit tests locally.
3440

3541
test-javascript-local: $(NODE_MODULES)
36-
NODE_ENV=$(NODE_ENV) \
37-
NODE_PATH=$(NODE_PATH_TEST) \
38-
$(JAVASCRIPT_TEST) \
39-
$(JAVASCRIPT_TEST_FLAGS) \
40-
$(TESTS) \
41-
| $(TAP_REPORTER)
42+
for test in $(TESTS); do \
43+
echo ''; \
44+
echo "Running test: $$test"; \
45+
$(JAVASCRIPT_TEST) \
46+
$(JAVASCRIPT_TEST_FLAGS) \
47+
$$test \
48+
| $(TAP_REPORTER) || exit 1; \
49+
done
4250

4351
.PHONY: test-javascript-local
4452

@@ -53,11 +61,13 @@ test-javascript-local: $(NODE_MODULES)
5361
# [1]: https://github.com/zoubin/tap-summary
5462

5563
test-javascript-summary: $(NODE_MODULES)
56-
NODE_ENV=$(NODE_ENV) \
57-
NODE_PATH=$(NODE_PATH_TEST) \
58-
$(JAVASCRIPT_TEST) \
59-
$(JAVASCRIPT_TEST_FLAGS) \
60-
$(TESTS) \
61-
| $(TAP_SUMMARY)
64+
for test in $(TESTS); do \
65+
echo ''; \
66+
echo "Running test: $$test"; \
67+
$(JAVASCRIPT_TEST) \
68+
$(JAVASCRIPT_TEST_FLAGS) \
69+
$$test \
70+
| $(TAP_SUMMARY) || exit 1; \
71+
done
6272

6373
.PHONY: test-javascript-summary

0 commit comments

Comments
 (0)