Browse Source

Add test-only dependencies

Loïc Hoguin 12 years ago
parent
commit
747cba4d71
2 changed files with 19 additions and 1 deletions
  1. 12 0
      README.md
  2. 7 1
      erlang.mk

+ 12 - 0
README.md

@@ -33,6 +33,18 @@ dep_bullet = https://github.com/extend/bullet.git 0.4.1
 
 
 They will always be compiled using the command `make`.
 They will always be compiled using the command `make`.
 
 
+You can also specify test-only dependencies. These dependencies will only
+be downloaded when running `make tests`. The format is the same as above,
+except the variable `TEST_DEPS` holds the list of test-only dependencies.
+
+``` erlang
+TEST_DEPS = ct_helper
+dep_ct_helper = https://github.com/extend/ct_helper.git master
+```
+
+Please note that the test dependencies will only be compiled once
+when they are fetched, unlike the normal dependencies.
+
 Commands
 Commands
 --------
 --------
 
 

+ 7 - 1
erlang.mk

@@ -34,6 +34,7 @@ DEPS_DIR ?= $(CURDIR)/deps
 export DEPS_DIR
 export DEPS_DIR
 
 
 ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DEPS))
 ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(DEPS))
+ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
 
 
 # Application.
 # Application.
 
 
@@ -94,7 +95,12 @@ clean-docs:
 
 
 # Tests.
 # Tests.
 
 
-build-tests:
+$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
+
+build-test-deps: $(ALL_TEST_DEPS_DIRS)
+	@for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
+
+build-tests: build-test-deps
 	$(gen_verbose) erlc -v $(ERLC_OPTS) -o test/ \
 	$(gen_verbose) erlc -v $(ERLC_OPTS) -o test/ \
 		$(wildcard test/*.erl test/*/*.erl) -pa ebin/
 		$(wildcard test/*.erl test/*/*.erl) -pa ebin/