Skip to content

Commit 8a3bbbb

Browse files
committed
Add rule for listing test fixtures
1 parent 0184603 commit 8a3bbbb

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ SOURCE_DIR ?= lib
5050
# Define the directory name for test files:
5151
TESTS_DIR ?= test
5252

53+
# Define the directory name for test fixtures:
54+
TESTS_FIXTURES_DIR ?= test/fixtures
55+
5356
# Define the directory name for examples files:
5457
EXAMPLES_DIR ?= examples
5558

tools/make/lib/find/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ TESTS_PATTERN ?= test*.js
1919
# Define a filepath pattern for test files:
2020
TESTS_FILTER ?= .*/.*
2121

22+
# Define a filename pattern for test fixtures:
23+
TESTS_FIXTURES_PATTERN ?= *.*
24+
25+
# Define a filepath pattern for test fixture files:
26+
TESTS_FIXTURES_FILTER ?= .*/.*
27+
2228
# Define a filename pattern for example files:
2329
EXAMPLES_PATTERN ?= *.js
2430

@@ -31,4 +37,5 @@ EXAMPLES_FILTER ?= .*/.*
3137
include $(TOOLS_MAKE_DIR)/lib/find/files.mk
3238
include $(TOOLS_MAKE_DIR)/lib/find/sources.mk
3339
include $(TOOLS_MAKE_DIR)/lib/find/tests.mk
40+
include $(TOOLS_MAKE_DIR)/lib/find/tests-fixtures.mk
3441
include $(TOOLS_MAKE_DIR)/lib/find/examples.mk
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
# VARIABLES #
3+
4+
# On Mac OSX, in order to use `|` and other regular expression operators, we need to use enhanced regular expression syntax (-E); see https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man7/re_format.7.html#//apple_ref/doc/man/7/re_format.
5+
6+
ifeq ($(KERNEL), Darwin)
7+
TESTS_FIXTURES ?= $(shell find -E $(ROOT) \
8+
-name "$(TESTS_FIXTURES_PATTERN)" \
9+
-path "$(ROOT)/**/$(TESTS_FIXTURES_DIR)/**" \
10+
-regex "$(TESTS_FIXTURES_FILTER)" \
11+
-not -path "$(ROOT)/.*" \
12+
-not -path "$(NODE_MODULES)/*" \
13+
-not -path "$(TOOLS_DIR)/*" \
14+
-not -path "$(BUILD_DIR)/*" \
15+
-not -path "$(REPORTS_DIR)/*" \
16+
)
17+
else
18+
TESTS_FIXTURES ?= $(shell find $(ROOT) \
19+
-name "$(TESTS_FIXTURES_PATTERN)" \
20+
-path "$(ROOT)/**/$(TESTS_FIXTURES_DIR)/**" \
21+
-regextype posix-extended \
22+
-regex "$(TESTS_FIXTURES_FILTER)" \
23+
-not -path "$(ROOT)/.*" \
24+
-not -path "$(NODE_MODULES)/*" \
25+
-not -path "$(TOOLS_DIR)/*" \
26+
-not -path "$(BUILD_DIR)/*" \
27+
-not -path "$(REPORTS_DIR)/*" \
28+
)
29+
endif
30+
31+
32+
# TARGETS #
33+
34+
# List test fixture files.
35+
#
36+
# This target prints a newline-delimited list of test fixture files.
37+
38+
list-test-fixtures:
39+
@printf '%s\n' $(TESTS_FIXTURES)
40+
41+
42+
.PHONY: list-test-fixtures

tools/make/usage.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Usage: make <cmd>
66
make list-sources List all source files (excluding examples and tests).
77
make list-examples List all example files.
88
make list-tests List all test files.
9+
make list-test-fixtures List all test fixture files.
910
make list-files List files.
1011
make examples Run examples.
1112
make test Run tests.

0 commit comments

Comments
 (0)