Skip to content

Commit f890de5

Browse files
committed
Add make commands for tap-min output
1 parent e22fdaf commit f890de5

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
"remark-vdom": "^8.0.0",
215215
"semver": "^6.0.0",
216216
"spdx-license-ids": "^3.0.0",
217+
"tap-min": "2.x.x",
217218
"tap-spec": "5.x.x",
218219
"tap-summary": "^4.0.0",
219220
"tap-xunit": "^2.2.0",

tools/make/common.mk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,17 @@ TAP_REPORTER ?= $(BIN_DIR)/tap-spec
295295
# [1]: https://github.com/zoubin/tap-summary
296296
TAP_SUMMARY ?= $(BIN_DIR)/tap-summary
297297

298+
# Define the path to the [`tap--min`][1] executable.
299+
#
300+
# To install `tap-min`:
301+
#
302+
# ```bash
303+
# $ npm install tap-min
304+
# ```
305+
#
306+
# [1]: https://github.com/derhuerst/tap-min
307+
TAP_MIN ?= $(BIN_DIR)/tap-min
308+
298309
# Define the path to the [`tap-xunit`][1] executable.
299310
#
300311
# To install `tap-xunit`:

tools/make/lib/test/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,45 @@ test-files-summary: test-javascript-files-summary
142142

143143
.PHONY: test-files-summary
144144

145+
#/
146+
# Runs unit tests and minimizes aggregated TAP output.
147+
#
148+
# ## Notes
149+
#
150+
# - This command is useful when wanting to glob for test files (e.g., run all tests for a particular package).
151+
#
152+
#
153+
# @param {string} [TESTS_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`)
154+
# @param {*} [FAST_FAIL] - flag indicating whether to stop running tests upon encountering a test failure
155+
#
156+
# @example
157+
# make test-min
158+
#
159+
# @example
160+
# make test-min TESTS_FILTER=".*/blas/base/dasum/.*"
161+
#/
162+
test-min: test-javascript-min
163+
164+
.PHONY: test-min
165+
166+
#/
167+
# Runs a specified list of files containing unit tests and minimizes aggregated TAP output.
168+
#
169+
# ## Notes
170+
#
171+
# - This rule is useful when wanting to run a list of test files generated by some other command (e.g., a list of changed test files obtained via `git diff`).
172+
#
173+
#
174+
# @param {string} FILES - list of test file paths
175+
# @param {*} [FAST_FAIL] - flag indicating whether to stop running tests upon encountering a test failure
176+
#
177+
# @example
178+
# make test-files-min FILES='/foo/test.js /bar/test.js'
179+
#/
180+
test-files-min: test-javascript-files-min
181+
182+
.PHONY: test-files-min
183+
145184
#/
146185
# Runs unit tests and generates raw TAP output.
147186
#

tools/make/lib/test/javascript.mk

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,93 @@ endif
253253

254254
.PHONY: test-javascript-files-summary
255255

256+
#/
257+
# Runs JavaScript unit tests and minimizes aggregated TAP output.
258+
#
259+
# ## Notes
260+
#
261+
# - This command is useful when wanting to glob for JavaScript test files (e.g., run all JavaScript tests for a particular package).
262+
#
263+
#
264+
# @param {string} [TESTS_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`)
265+
# @param {string} [JAVASCRIPT_TEST_RUNNER] - JavaScript test runner
266+
# @param {*} [FAST_FAIL] - flag indicating whether to stop running tests upon encountering a test failure
267+
#
268+
# @example
269+
# make test-javascript-min
270+
#
271+
# @example
272+
# make test-javascript-min TESTS_FILTER=".*/blas/base/dasum/.*"
273+
#/
274+
test-javascript-min: $(NODE_MODULES)
275+
ifeq ($(FAIL_FAST), true)
276+
$(QUIET) $(FIND_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r test; do \
277+
echo ''; \
278+
echo "Running test: $$test"; \
279+
NODE_ENV="$(NODE_ENV_TEST)" \
280+
NODE_PATH="$(NODE_PATH_TEST)" \
281+
$(NODE) $(NODE_FLAGS_TEST) $(JAVASCRIPT_TEST) \
282+
$(JAVASCRIPT_TEST_FLAGS) \
283+
$$test \
284+
| $(TAP_MIN) || exit 1; \
285+
done
286+
else
287+
$(QUIET) $(FIND_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r test; do \
288+
echo ''; \
289+
echo "Running test: $$test"; \
290+
NODE_ENV="$(NODE_ENV_TEST)" \
291+
NODE_PATH="$(NODE_PATH_TEST)" \
292+
$(NODE) $(NODE_FLAGS_TEST) $(JAVASCRIPT_TEST) \
293+
$(JAVASCRIPT_TEST_FLAGS) \
294+
$$test \
295+
| $(TAP_MIN) || echo 'Tests failed.'; \
296+
done
297+
endif
298+
299+
.PHONY: test-javascript-min
300+
301+
#/
302+
# Runs a specified list of files containing JavaScript unit tests and minimizes aggregated TAP output.
303+
#
304+
# ## Notes
305+
#
306+
# - This rule is useful when wanting to run a list of JavaScript test files generated by some other command (e.g., a list of changed JavaScript test files obtained via `git diff`).
307+
#
308+
#
309+
# @param {string} FILES - list of JavaScript test file paths
310+
# @param {string} [JAVASCRIPT_TEST_RUNNER] - JavaScript test runner
311+
# @param {*} [FAST_FAIL] - flag indicating whether to stop running tests upon encountering a test failure
312+
#
313+
# @example
314+
# make test-javascript-files-min FILES='/foo/test.js /bar/test.js'
315+
#/
316+
test-javascript-files-min: $(NODE_MODULES)
317+
ifeq ($(FAIL_FAST), true)
318+
$(QUIET) for test in $(FILES); do \
319+
echo ''; \
320+
echo "Running test: $$test"; \
321+
NODE_ENV="$(NODE_ENV_TEST)" \
322+
NODE_PATH="$(NODE_PATH_TEST)" \
323+
$(NODE) $(NODE_FLAGS_TEST) $(JAVASCRIPT_TEST) \
324+
$(JAVASCRIPT_TEST_FLAGS) \
325+
$$test \
326+
| $(TAP_MIN) || exit 1; \
327+
done
328+
else
329+
$(QUIET) for test in $(FILES); do \
330+
echo ''; \
331+
echo "Running test: $$test"; \
332+
NODE_ENV="$(NODE_ENV_TEST)" \
333+
NODE_PATH="$(NODE_PATH_TEST)" \
334+
$(NODE) $(NODE_FLAGS_TEST) $(JAVASCRIPT_TEST) \
335+
$(JAVASCRIPT_TEST_FLAGS) \
336+
$$test \
337+
| $(TAP_MIN) || echo 'Tests failed.'; \
338+
done
339+
endif
340+
341+
.PHONY: test-javascript-files-min
342+
256343
#/
257344
# Runs JavaScript unit tests and generates raw TAP output.
258345
#

0 commit comments

Comments
 (0)