ct.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Copyright (c) 2013-2014, 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: build-ct-deps build-ct-suites tests-ct clean-ct distclean-ct
  4. # Configuration.
  5. CT_OPTS ?=
  6. CT_SUITES ?=
  7. TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard
  8. TEST_ERLC_OPTS += -DTEST=1 -DEXTRA=1 +'{parse_transform, eunit_autoexport}'
  9. # Core targets.
  10. tests:: tests-ct
  11. clean:: clean-ct
  12. distclean:: distclean-ct
  13. help::
  14. @printf "%s\n" "" \
  15. "All your common_test suites have their associated targets." \
  16. "A suite named http_SUITE can be ran using the ct-http target."
  17. # Plugin-specific targets.
  18. ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS))
  19. CT_RUN = ct_run \
  20. -no_auto_compile \
  21. -noshell \
  22. -pa $(realpath ebin) $(DEPS_DIR)/*/ebin \
  23. -dir test \
  24. -logdir logs
  25. $(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep))))
  26. build-ct-deps: $(ALL_TEST_DEPS_DIRS)
  27. @for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
  28. build-ct-suites: build-ct-deps
  29. $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -o test/ \
  30. $(wildcard test/*.erl test/*/*.erl) -pa ebin/
  31. tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS)
  32. tests-ct: clean deps app build-ct-suites
  33. @if [ -d "test" ] ; \
  34. then \
  35. mkdir -p logs/ ; \
  36. $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS) ; \
  37. fi
  38. $(gen_verbose) rm -f test/*.beam
  39. define ct_suite_target
  40. ct-$(1): ERLC_OPTS = $(TEST_ERLC_OPTS)
  41. ct-$(1): clean deps app build-tests
  42. @if [ -d "test" ] ; \
  43. then \
  44. mkdir -p logs/ ; \
  45. $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS) ; \
  46. fi
  47. $(gen_verbose) rm -f test/*.beam
  48. endef
  49. $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test))))
  50. clean-ct:
  51. $(gen_verbose) rm -rf test/*.beam
  52. distclean-ct:
  53. $(gen_verbose) rm -rf logs/