proper.mk 1.6 KB

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