Skip to content

Commit f9cd545

Browse files
committed
Add recipes to run tools tests and generate a coverage report
1 parent 8c32770 commit f9cd545

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

tools/make/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ 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
5353
include $(TOOLS_MAKE_LIB_DIR)/tools-test/Makefile
54+
include $(TOOLS_MAKE_LIB_DIR)/tools-test-cov/Makefile
5455
include $(TOOLS_MAKE_LIB_DIR)/workshops/Makefile
5556

5657

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
# DEPENDENCIES #
3+
4+
include $(TOOLS_MAKE_LIB_DIR)/tools-test-cov/javascript.mk
5+
6+
7+
# TARGETS #
8+
9+
# Run units and generate a test coverage report.
10+
#
11+
# This target instruments source code, runs unit tests, and outputs a test coverage report.
12+
13+
tools-test-cov: tools-test-javascript-cov
14+
15+
.PHONY: tools-test-cov
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
# TARGETS #
3+
4+
# Run unit tests and generate a test coverage report.
5+
#
6+
# This target instruments source code, runs unit tests, and outputs a test coverage report.
7+
8+
tools-test-istanbul:
9+
$(QUIET) NODE_ENV=$(NODE_ENV_TEST) \
10+
NODE_PATH=$(NODE_PATH_TEST) \
11+
$(ISTANBUL_COVER) \
12+
--dir $(COVERAGE_DIR) \
13+
--report $(ISTANBUL_COVER_REPORT_FORMAT) \
14+
$(JAVASCRIPT_TEST) -- \
15+
$(JAVASCRIPT_TEST_FLAGS) \
16+
$(TOOLS_TESTS)
17+
18+
.PHONY: tools-test-istanbul
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# VARIABLES #
3+
4+
# Define the Node environment:
5+
NODE_ENV_TEST ?= $(NODE_ENV)
6+
7+
# Define the Node path:
8+
NODE_PATH_TEST ?= $(NODE_PATH)
9+
10+
# Define the code coverage instrumentation utility:
11+
JAVASCRIPT_CODE_INSTRUMENTER ?= istanbul
12+
13+
14+
# DEPENDENCIES #
15+
16+
ifeq ($(JAVASCRIPT_CODE_INSTRUMENTER), istanbul)
17+
include $(TOOLS_MAKE_LIB_DIR)/tools-test-cov/istanbul.mk
18+
endif
19+
20+
21+
# TARGETS #
22+
23+
# Run unit tests and generate a test coverage report.
24+
#
25+
# This target instruments JavaScript source code, runs unit tests, and outputs a test coverage report.
26+
27+
tools-test-javascript-cov:
28+
ifeq ($(JAVASCRIPT_CODE_INSTRUMENTER), istanbul)
29+
$(QUIET) $(MAKE) -f $(this_file) tools-test-istanbul
30+
endif
31+
32+
.PHONY: tools-test-javascript-cov

0 commit comments

Comments
 (0)