triq.mk 1.2 KB

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