Skip to content

Commit e98550a

Browse files
committed
Add Makefile recipes to run tools tests
1 parent a10016a commit e98550a

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

tools/make/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ include $(TOOLS_MAKE_LIB_DIR)/test/Makefile
5050
include $(TOOLS_MAKE_LIB_DIR)/test-browsers/Makefile
5151
include $(TOOLS_MAKE_LIB_DIR)/test-ci/Makefile
5252
include $(TOOLS_MAKE_LIB_DIR)/test-cov/Makefile
53+
include $(TOOLS_MAKE_LIB_DIR)/tools-test/Makefile
5354
include $(TOOLS_MAKE_LIB_DIR)/workshops/Makefile
5455

5556

tools/make/lib/tools-test/Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
# VARIABLES #
3+
4+
# Define the path to the `tap-spec` executable:
5+
#
6+
# To install tap-spec:
7+
# $ npm install tap-spec
8+
#
9+
# [1]: https://github.com/scottcorgan/tap-spec
10+
TAP_REPORTER ?= $(BIN_DIR)/tap-spec
11+
12+
# Define the path to the `tap-summary` executable:
13+
#
14+
# To install tap-summary:
15+
# $ npm install tap-summary
16+
#
17+
# [1]: https://github.com/zoubin/tap-summary
18+
TAP_SUMMARY ?= $(BIN_DIR)/tap-summary
19+
20+
21+
# DEPENDENCIES #
22+
23+
include $(TOOLS_MAKE_LIB_DIR)/tools-test/javascript.mk
24+
25+
26+
# TARGETS #
27+
28+
# Run unit tests.
29+
#
30+
# This target runs unit tests.
31+
32+
tools-test: tools-test-javascript
33+
34+
.PHONY: tools-test
35+
36+
37+
# Generate a test summary.
38+
#
39+
# This target runs unit tests and aggregates TAP output as a test summary.
40+
41+
tools-test-summary: tools-test-javascript-summary
42+
43+
.PHONY: tools-test-summary
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
# VARIABLES #
3+
4+
# Define the command for setting executable permissions:
5+
MAKE_EXECUTABLE ?= chmod +x
6+
7+
# Define the Node environment:
8+
NODE_ENV_TEST ?= $(NODE_ENV)
9+
10+
# Define the Node path:
11+
NODE_PATH_TEST ?= $(NODE_PATH)
12+
13+
# Define the test runner to use when running JavaScript tests:
14+
JAVASCRIPT_TEST_RUNNER ?= tape
15+
16+
# Define test runner to use when running JavaScript tests across multiple Node.js versions:
17+
JAVASCRIPT_TEST_NODE_VERSIONS ?= $(TOOLS_DIR)/test/scripts/test_node_versions
18+
19+
# Define the command-line options to be used when invoking the versions runner:
20+
JAVASCRIPT_TEST_NODE_VERSIONS_FLAGS ?= \
21+
--versions $(NODE_VERSIONS)
22+
23+
24+
# DEPENDENCIES #
25+
26+
ifeq ($(JAVASCRIPT_TEST_RUNNER), tape)
27+
include $(TOOLS_MAKE_LIB_DIR)/test/tape.mk
28+
endif
29+
30+
31+
# TARGETS #
32+
33+
# Run JavaScript unit tests.
34+
#
35+
# This target runs JavaScript unit tests using a specified test runner and pipes TAP output to a reporter.
36+
37+
tools-test-javascript: $(NODE_MODULES)
38+
$(QUIET) for test in $(TOOLS_TESTS); do \
39+
echo ''; \
40+
echo "Running test: $$test"; \
41+
NODE_ENV=$(NODE_ENV_TEST) \
42+
NODE_PATH=$(NODE_PATH_TEST) \
43+
$(JAVASCRIPT_TEST) \
44+
$(JAVASCRIPT_TEST_FLAGS) \
45+
$$test \
46+
| $(TAP_REPORTER) || exit 1; \
47+
done
48+
49+
.PHONY: tools-test-javascript
50+
51+
52+
# Generate a JavaScript test summary.
53+
#
54+
# This target runs JavaScript unit tests and aggregates TAP output as a test summary.
55+
56+
tools-test-javascript-summary: $(NODE_MODULES)
57+
$(QUIET) for test in $(TOOLS_TESTS); do \
58+
echo ''; \
59+
echo "Running test: $$test"; \
60+
NODE_ENV=$(NODE_ENV_TEST) \
61+
NODE_PATH=$(NODE_PATH_TEST) \
62+
$(JAVASCRIPT_TEST) \
63+
$(JAVASCRIPT_TEST_FLAGS) \
64+
$$test \
65+
| $(TAP_SUMMARY) || exit 1; \
66+
done
67+
68+
.PHONY: tools-test-javascript-summary
69+
70+
71+
# Run unit tests against Node.js versions.
72+
#
73+
# This targets runs JavaScript unit tests against specific Node.js versions.
74+
75+
tools-test-node-versions: $(NODE_MODULES)
76+
$(QUIET) $(MAKE_EXECUTABLE) $(JAVASCRIPT_TEST_NODE_VERSIONS)
77+
$(QUIET) $(JAVASCRIPT_TEST_NODE_VERSIONS) $(JAVASCRIPT_TEST_NODE_VERSIONS_FLAGS) $(TOOLS_TESTS)
78+
79+
.PHONY: tools-test-node-versions

0 commit comments

Comments
 (0)