proper.mk 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (c) 2015-2017, 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 proper,$(DEPS) $(TEST_DEPS)),proper)
  4. .PHONY: proper
  5. # Targets.
  6. tests:: proper
  7. define proper_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. Module = fun(M) ->
  13. [true] =:= lists:usort([
  14. case atom_to_list(F) of
  15. "prop_" ++ _ ->
  16. io:format("Testing ~p:~p/0~n", [M, F]),
  17. proper:quickcheck(M:F(), nocolors);
  18. _ ->
  19. true
  20. end
  21. || {F, 0} <- M:module_info(exports)])
  22. end,
  23. try
  24. case $(1) of
  25. all -> [true] =:= lists:usort([Module(M) || M <- [$(call comma_list,$(3))]]);
  26. module -> Module($(2));
  27. function -> proper:quickcheck($(2), nocolors)
  28. end
  29. of
  30. true -> halt(0);
  31. _ -> halt(1)
  32. catch error:undef ->
  33. io:format("Undefined property or module?~n~p~n", [erlang:get_stacktrace()]),
  34. halt(0)
  35. end.
  36. endef
  37. ifdef t
  38. ifeq (,$(findstring :,$(t)))
  39. proper: test-build
  40. $(verbose) $(call erlang,$(call proper_check.erl,module,$(t)))
  41. else
  42. proper: test-build
  43. $(verbose) echo Testing $(t)/0
  44. $(verbose) $(call erlang,$(call proper_check.erl,function,$(t)()))
  45. endif
  46. else
  47. proper: test-build
  48. $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename \
  49. $(wildcard ebin/*.beam) $(call core_find,$(TEST_DIR)/,*.beam))))))
  50. $(gen_verbose) $(call erlang,$(call proper_check.erl,all,undefined,$(MODULES)))
  51. endif
  52. endif