Skip to content

Commit 1ce6e38

Browse files
committed
Add recipe for converting TAP output to xUnit XML
1 parent 9bb38b6 commit 1ce6e38

2 files changed

Lines changed: 73 additions & 24 deletions

File tree

tools/make/lib/test/Makefile

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,29 @@
22
# VARIABLES #
33

44
# 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
510
TAP_REPORTER ?= $(BIN_DIR)/tap-spec
611

712
# 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
818
TAP_SUMMARY ?= $(BIN_DIR)/tap-summary
919

20+
# Define the path to the `tap-xunit` executable:
21+
#
22+
# To install tap-xunit:
23+
# $ npm install tap-xunit
24+
#
25+
# [1]: https://github.com/aghassemi/tap-xunit
26+
TAP_XUNIT ?= $(BIN_DIR)/tap-xunit
27+
1028

1129
# DEPENDENCIES #
1230

@@ -17,12 +35,7 @@ include $(TOOLS_MAKE_LIB_DIR)/test/javascript.mk
1735

1836
# Run unit tests.
1937
#
20-
# This target runs unit tests using a specified test runner and pipes TAP output to a reporter which is expected to be [tap-spec][1].
21-
#
22-
# To install tap-spec:
23-
# $ npm install tap-spec
24-
#
25-
# [1]: https://github.com/scottcorgan/tap-spec
38+
# This target runs unit tests.
2639

2740
test: test-local
2841

@@ -40,13 +53,26 @@ test-local: test-javascript-local
4053

4154
# Generate a test summary.
4255
#
43-
# This target runs unit tests and aggregates TAP output as a test summary. The test summary is expected to be generated by [tap-summary][1].
44-
#
45-
# To install tap-summary:
46-
# $ npm install tap-summary
47-
#
48-
# [1]: https://github.com/zoubin/tap-summary
56+
# This target runs unit tests and aggregates TAP output as a test summary.
4957

5058
test-summary: test-javascript-summary
5159

5260
.PHONY: test-summary
61+
62+
63+
# Generate TAP output.
64+
#
65+
# This target runs unit tests and streams raw TAP output.
66+
67+
test-tap: test-javascript-tap
68+
69+
.PHONY: test-tap
70+
71+
72+
# Generate a xUnit XML.
73+
#
74+
# This target runs unit tests and converts TAP output to xUnit XML.
75+
76+
test-xunit: test-javascript-xunit
77+
78+
.PHONY: test-xunit

tools/make/lib/test/javascript.mk

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ endif
2222

2323
# Run JavaScript unit tests.
2424
#
25-
# This target runs JavaScript unit tests using a specified test runner and pipes TAP output to a reporter which is expected to be [tap-spec][1].
26-
#
27-
# To install tap-spec:
28-
# $ npm install tap-spec
29-
#
30-
# [1]: https://github.com/scottcorgan/tap-spec
25+
# This target runs JavaScript unit tests using a specified test runner and pipes TAP output to a reporter.
3126

3227
test-javascript: test-javascript-local
3328

@@ -55,12 +50,7 @@ test-javascript-local: $(NODE_MODULES)
5550

5651
# Generate a JavaScript test summary.
5752
#
58-
# This target runs JavaScript unit tests and aggregates TAP output as a test summary. The test summary is expected to be generated by [tap-summary][1].
59-
#
60-
# To install tap-summary:
61-
# $ npm install tap-summary
62-
#
63-
# [1]: https://github.com/zoubin/tap-summary
53+
# This target runs JavaScript unit tests and aggregates TAP output as a test summary.
6454

6555
test-javascript-summary: $(NODE_MODULES)
6656
$(QUIET) for test in $(TESTS); do \
@@ -75,3 +65,36 @@ test-javascript-summary: $(NODE_MODULES)
7565
done
7666

7767
.PHONY: test-javascript-summary
68+
69+
70+
# Generate TAP output.
71+
#
72+
# This target runs JavaScript unit tests and streams raw TAP output.
73+
74+
test-javascript-tap: $(NODE_MODULES)
75+
$(QUIET) for test in $(TESTS); do \
76+
NODE_ENV=$(NODE_ENV_TEST) \
77+
NODE_PATH=$(NODE_PATH_TEST) \
78+
$(JAVASCRIPT_TEST) \
79+
$(JAVASCRIPT_TEST_FLAGS) \
80+
$$test; \
81+
done
82+
83+
.PHONY: test-javascript-tap
84+
85+
86+
# Generate xUnit XML output.
87+
#
88+
# This target runs JavaScript unit tests and converts TAP output to xUnit XML.
89+
90+
test-javascript-xunit: $(NODE_MODULES)
91+
$(QUIET) for test in $(TESTS); do \
92+
NODE_ENV=$(NODE_ENV_TEST) \
93+
NODE_PATH=$(NODE_PATH_TEST) \
94+
$(JAVASCRIPT_TEST) \
95+
$(JAVASCRIPT_TEST_FLAGS) \
96+
$$test \
97+
| $(TAP_XUNIT) || exit 1; \
98+
done
99+
100+
.PHONY: test-javascript-xunit

0 commit comments

Comments
 (0)