ct.mk 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. .PHONY: ct distclean-ct
  4. # Configuration.
  5. CT_OPTS ?=
  6. ifneq ($(wildcard $(TEST_DIR)),)
  7. CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(notdir $(call core_find,$(TEST_DIR)/,*_SUITE.erl))))
  8. else
  9. CT_SUITES ?=
  10. endif
  11. # Core targets.
  12. tests:: ct
  13. distclean:: distclean-ct
  14. help::
  15. @printf "%s\n" "" \
  16. "Common_test targets:" \
  17. " ct Run all the common_test suites for this project" \
  18. "" \
  19. "All your common_test suites have their associated targets." \
  20. "A suite named http_SUITE can be ran using the ct-http target."
  21. # Plugin-specific targets.
  22. CT_RUN = ct_run \
  23. -no_auto_compile \
  24. -noinput \
  25. -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin $(TEST_DIR) \
  26. -dir $(TEST_DIR) \
  27. -logdir $(CURDIR)/logs
  28. ifeq ($(CT_SUITES),)
  29. ct:
  30. else
  31. ct: test-build
  32. @mkdir -p $(CURDIR)/logs/
  33. $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
  34. endif
  35. define ct_suite_target
  36. ct-$(1): test-build
  37. @mkdir -p $(CURDIR)/logs/
  38. $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS)
  39. endef
  40. $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
  41. distclean-ct:
  42. $(gen_verbose) rm -rf $(CURDIR)/logs/