Skip to content

Commit 05be7aa

Browse files
devonestesJosé Valim
authored andcommitted
Allow running a single test file from make (#9669)
One thing I've found myself wanting quite a lot when working on Elixir is the ability to run single tests, or at least single test files, easily with `make test_stdlib` or something. With this change this is now possible - you can run `make test_stdlib TEST_FILES=macro_test.exs` to just run that file, or `make test_ex_unit TEST_FILE=ex_unit/formatter_test.exs`.
1 parent 203d540 commit 05be7aa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
PREFIX ?= /usr/local
2+
TEST_FILES ?= "*_test.exs"
23
SHARE_PREFIX ?= $(PREFIX)/share
34
MAN_PREFIX ?= $(SHARE_PREFIX)/man
45
CANONICAL := master/ # master/ or vMAJOR.MINOR/
@@ -45,7 +46,7 @@ lib/$(1)/ebin/Elixir.$(2).beam: $(wildcard lib/$(1)/lib/*.ex) $(wildcard lib/$(1
4546

4647
test_$(1): compile $(1)
4748
@ echo "==> $(1) (ex_unit)"
48-
$(Q) cd lib/$(1) && ../../bin/elixir -r "test/test_helper.exs" -pr "test/**/*_test.exs";
49+
$(Q) cd lib/$(1) && ../../bin/elixir -r "test/test_helper.exs" -pr "test/**/$(TEST_FILES)";
4950
endef
5051

5152
define WRITE_SOURCE_DATE_EPOCH
@@ -281,9 +282,9 @@ test_stdlib: compile
281282
@ echo "==> elixir (ex_unit)"
282283
$(Q) exec epmd & exit
283284
$(Q) if [ "$(OS)" = "Windows_NT" ]; then \
284-
cd lib/elixir && cmd //C call ../../bin/elixir.bat -r "test/elixir/test_helper.exs" -pr "test/elixir/**/*_test.exs"; \
285+
cd lib/elixir && cmd //C call ../../bin/elixir.bat -r "test/elixir/test_helper.exs" -pr "test/elixir/**/$(TEST_FILES)"; \
285286
else \
286-
cd lib/elixir && ../../bin/elixir -r "test/elixir/test_helper.exs" -pr "test/elixir/**/*_test.exs"; \
287+
cd lib/elixir && ../../bin/elixir -r "test/elixir/test_helper.exs" -pr "test/elixir/**/$(TEST_FILES)"; \
287288
fi
288289

289290
#==> Dialyzer tasks

0 commit comments

Comments
 (0)