ct.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # Copyright (c) 2013-2016, 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 apps-ct distclean-ct
  4. # Configuration.
  5. CT_OPTS ?=
  6. ifneq ($(wildcard $(TEST_DIR)),)
  7. ifndef CT_SUITES
  8. CT_SUITES := $(sort $(subst _SUITE.erl,,$(notdir $(call core_find,$(TEST_DIR)/,*_SUITE.erl))))
  9. endif
  10. endif
  11. CT_SUITES ?=
  12. # Core targets.
  13. tests:: ct
  14. distclean:: distclean-ct
  15. help::
  16. $(verbose) printf "%s\n" "" \
  17. "Common_test targets:" \
  18. " ct Run all the common_test suites for this project" \
  19. "" \
  20. "All your common_test suites have their associated targets." \
  21. "A suite named http_SUITE can be ran using the ct-http target."
  22. # Plugin-specific targets.
  23. CT_RUN = ct_run \
  24. -no_auto_compile \
  25. -noinput \
  26. -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin $(APPS_DIR)/*/ebin $(TEST_DIR) \
  27. -dir $(TEST_DIR) \
  28. -logdir $(CURDIR)/logs
  29. ifeq ($(CT_SUITES),)
  30. ct: $(if $(IS_APP),,apps-ct)
  31. else
  32. ct: test-build $(if $(IS_APP),,apps-ct)
  33. $(verbose) mkdir -p $(CURDIR)/logs/
  34. $(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
  35. endif
  36. ifneq ($(ALL_APPS_DIRS),)
  37. define ct_app_target
  38. apps-ct-$1:
  39. $(MAKE) -C $1 ct IS_APP=1
  40. endef
  41. $(foreach app,$(ALL_APPS_DIRS),$(eval $(call ct_app_target,$(app))))
  42. apps-ct: test-build $(addprefix apps-ct-,$(ALL_APPS_DIRS))
  43. endif
  44. ifndef t
  45. CT_EXTRA =
  46. else
  47. ifeq (,$(findstring :,$t))
  48. CT_EXTRA = -group $t
  49. else
  50. t_words = $(subst :, ,$t)
  51. CT_EXTRA = -group $(firstword $(t_words)) -case $(lastword $(t_words))
  52. endif
  53. endif
  54. define ct_suite_target
  55. ct-$(1): test-build
  56. $(verbose) mkdir -p $(CURDIR)/logs/
  57. $(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(1)) $(CT_EXTRA) $(CT_OPTS)
  58. endef
  59. $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
  60. distclean-ct:
  61. $(gen_verbose) rm -rf $(CURDIR)/logs/