proper.mk 1.4 KB

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