ct.mk 1.8 KB

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