ct.mk 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 $(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) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
  34. endif
  35. ifneq ($(ALL_APPS_DIRS),)
  36. apps-ct:
  37. $(verbose) for app in $(ALL_APPS_DIRS); do $(MAKE) -C $$app ct IS_APP=1; done
  38. endif
  39. ifndef t
  40. CT_EXTRA =
  41. else
  42. ifeq (,$(findstring :,$t))
  43. CT_EXTRA = -group $t
  44. else
  45. t_words = $(subst :, ,$t)
  46. CT_EXTRA = -group $(firstword $(t_words)) -case $(lastword $(t_words))
  47. endif
  48. endif
  49. define ct_suite_target
  50. ct-$(1): test-build
  51. $(verbose) mkdir -p $(CURDIR)/logs/
  52. $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_EXTRA) $(CT_OPTS)
  53. endef
  54. $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
  55. distclean-ct:
  56. $(gen_verbose) rm -rf $(CURDIR)/logs/