triq.mk 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (c) 2015-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. ifeq ($(filter triq,$(DEPS) $(TEST_DEPS)),triq)
  4. .PHONY: triq
  5. # Targets.
  6. tests:: triq
  7. define triq_check.erl
  8. $(call cover.erl)
  9. code:add_pathsa([
  10. "$(call core_native_path,$(CURDIR)/ebin)",
  11. "$(call core_native_path,$(DEPS_DIR)/*/ebin)",
  12. "$(call core_native_path,$(TEST_DIR))"]),
  13. try begin
  14. CoverSetup(),
  15. Res = case $(1) of
  16. all -> [true] =:= lists:usort([triq:check(M) || M <- [$(call comma_list,$(3))]]);
  17. module -> triq:check($(2));
  18. function -> triq:check($(2))
  19. end,
  20. CoverExport("$(COVER_DATA_DIR)/triq.coverdata"),
  21. Res
  22. end of
  23. true -> halt(0);
  24. _ -> halt(1)
  25. catch error:undef ->
  26. io:format("Undefined property or module?~n~p~n", [erlang:get_stacktrace()]),
  27. halt(0)
  28. end.
  29. endef
  30. ifdef t
  31. ifeq (,$(findstring :,$(t)))
  32. triq: test-build cover-data-dir
  33. $(verbose) $(call erlang,$(call triq_check.erl,module,$(t)))
  34. else
  35. triq: test-build cover-data-dir
  36. $(verbose) echo Testing $(t)/0
  37. $(verbose) $(call erlang,$(call triq_check.erl,function,$(t)()))
  38. endif
  39. else
  40. triq: test-build cover-data-dir
  41. $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename \
  42. $(wildcard ebin/*.beam) $(call core_find,$(TEST_DIR)/,*.beam))))))
  43. $(gen_verbose) $(call erlang,$(call triq_check.erl,all,undefined,$(MODULES)))
  44. endif
  45. endif