triq.mk 1.1 KB

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