ct.mk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. # We do not run tests if we are in an apps/* with no test directory.
  34. ifneq ($(IS_APP)$(wildcard $(TEST_DIR)),1)
  35. ct: test-build $(if $(IS_APP),,apps-ct)
  36. $(verbose) mkdir -p $(CT_LOGS_DIR)
  37. $(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
  38. endif
  39. endif
  40. ifneq ($(ALL_APPS_DIRS),)
  41. define ct_app_target
  42. apps-ct-$1:
  43. $(MAKE) -C $1 ct IS_APP=1
  44. endef
  45. $(foreach app,$(ALL_APPS_DIRS),$(eval $(call ct_app_target,$(app))))
  46. apps-ct: test-build $(addprefix apps-ct-,$(ALL_APPS_DIRS))
  47. endif
  48. ifndef t
  49. CT_EXTRA =
  50. else
  51. ifeq (,$(findstring :,$t))
  52. CT_EXTRA = -group $t
  53. else
  54. t_words = $(subst :, ,$t)
  55. CT_EXTRA = -group $(firstword $(t_words)) -case $(lastword $(t_words))
  56. endif
  57. endif
  58. define ct_suite_target
  59. ct-$(1): test-build
  60. $(verbose) mkdir -p $(CT_LOGS_DIR)
  61. $(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(1)) $(CT_EXTRA) $(CT_OPTS)
  62. endef
  63. $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
  64. distclean-ct:
  65. $(gen_verbose) rm -rf $(CT_LOGS_DIR)