Просмотр исходного кода

Add targets for individual test suites

Loïc Hoguin 11 лет назад
Родитель
Сommit
6b42bd74b6
2 измененных файлов с 21 добавлено и 3 удалено
  1. 7 1
      README.md
  2. 14 2
      erlang.mk

+ 7 - 1
README.md

@@ -104,7 +104,8 @@ The following targets are defined:
 | `clean-deps` | Clean the dependencies                       |
 | `docs`       | Generate the Edoc documentation              |
 | `clean-docs` | Clean the Edoc documentation                 |
-| `tests`      | Run the common_test suites                   |
+| `test_*`     | Run the common_test suite `*`                |
+| `tests`      | Run all the common_test suites               |
 | `build-plt`  | Generate the PLT needed by Dialyzer          |
 | `dialyze`    | Run Dialyzer on the application              |
 | `pkg-list`   | List packages in the index                   |
@@ -116,6 +117,11 @@ Dependencies are fetched as soon as a command involving them is
 invoked. This means that most of the targets will trigger a
 dependency fetch. It is only done once per dependency.
 
+You can run an individual test suite by using the special `test_*`
+targets. For example if you have a common_test suite named `spdy`
+and you want to run only this suite and not the others, you can
+use the `make test_spdy` command.
+
 The default target when calling `make` is `all`.
 
 You can combine targets to perform many operations. For example, the

+ 14 - 2
erlang.mk

@@ -183,14 +183,26 @@ CT_RUN = ct_run \
 #	-cover test/cover.spec
 
 CT_SUITES ?=
-CT_SUITES_FULL = $(addsuffix _SUITE,$(CT_SUITES))
+
+define test_target
+test_$(1): ERLC_OPTS += -DTEST=1 +'{parse_transform, eunit_autoexport}'
+test_$(1): clean deps app build-tests
+	@if [ -d "test" ] ; \
+	then \
+		mkdir -p logs/ ; \
+		$(CT_RUN) -suite $(addsuffix _SUITE,$(1)) ; \
+	fi
+	$(gen_verbose) rm -f test/*.beam
+endef
+
+$(foreach test,$(CT_SUITES),$(eval $(call test_target,$(test))))
 
 tests: ERLC_OPTS += -DTEST=1 +'{parse_transform, eunit_autoexport}'
 tests: clean deps app build-tests
 	@if [ -d "test" ] ; \
 	then \
 		mkdir -p logs/ ; \
-		$(CT_RUN) -suite $(CT_SUITES_FULL) ; \
+		$(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) ; \
 	fi
 	$(gen_verbose) rm -f test/*.beam