ct.mk 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 apps-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. $(verbose) 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 $(APPS_DIR)/*/ebin $(TEST_DIR) \
  26. -dir $(TEST_DIR) \
  27. -logdir $(CURDIR)/logs
  28. ifeq ($(CT_SUITES),)
  29. ct: $(if $(IS_APP),,apps-ct)
  30. else
  31. ct: test-build $(if $(IS_APP),,apps-ct)
  32. $(verbose) mkdir -p $(CURDIR)/logs/
  33. $(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
  34. endif
  35. ifneq ($(ALL_APPS_DIRS),)
  36. define ct_app_target
  37. apps-ct-$1:
  38. $(MAKE) -C $1 ct IS_APP=1
  39. endef
  40. $(foreach app,$(ALL_APPS_DIRS),$(eval $(call ct_app_target,$(app))))
  41. apps-ct: test-build $(addprefix apps-ct-,$(ALL_APPS_DIRS))
  42. endif
  43. ifndef t
  44. CT_EXTRA =
  45. else
  46. ifeq (,$(findstring :,$t))
  47. CT_EXTRA = -group $t
  48. else
  49. t_words = $(subst :, ,$t)
  50. CT_EXTRA = -group $(firstword $(t_words)) -case $(lastword $(t_words))
  51. endif
  52. endif
  53. define ct_suite_target
  54. ct-$(1): test-build
  55. $(verbose) mkdir -p $(CURDIR)/logs/
  56. $(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(1)) $(CT_EXTRA) $(CT_OPTS)
  57. endef
  58. $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
  59. distclean-ct:
  60. $(gen_verbose) rm -rf $(CURDIR)/logs/