|
| 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