triq.mk 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) 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. ifneq ($(wildcard $(DEPS_DIR)/triq),)
  4. .PHONY: triq
  5. # Targets.
  6. tests:: triq
  7. define triq_check.erl
  8. code:add_pathsa(["$(CURDIR)/ebin", "$(DEPS_DIR)/*/ebin"]),
  9. try
  10. case $(1) of
  11. all -> [true] =:= lists:usort([triq:check(M) || M <- [$(MODULES)]]);
  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. @$(call erlang,$(call triq_check.erl,module,$(t)))
  27. else
  28. triq: test-build
  29. @echo Testing $(t)/0
  30. @$(call erlang,$(call triq_check.erl,function,$(t)()))
  31. endif
  32. else
  33. triq: test-build
  34. $(eval MODULES := $(shell find ebin -type f -name \*.beam \
  35. | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
  36. $(gen_verbose) $(call erlang,$(call triq_check.erl,all,undefined))
  37. endif
  38. endif