From ff271594f58dc7425483fe3ccc649defc552a04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 10 Jul 2017 12:07:12 +0200 Subject: Add initial plugin for proper Should act the same way as the Triq plugin, making switching mostly painless, excluding the differences between the two libraries. --- build.config | 1 + plugins/proper.mk | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/triq.mk | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 plugins/proper.mk diff --git a/build.config b/build.config index 7bfcec7..6a28ce9 100644 --- a/build.config +++ b/build.config @@ -30,6 +30,7 @@ plugins/edoc plugins/erlydtl plugins/escript plugins/eunit +plugins/proper plugins/relx plugins/shell plugins/syntastic diff --git a/plugins/proper.mk b/plugins/proper.mk new file mode 100644 index 0000000..d6ae48e --- /dev/null +++ b/plugins/proper.mk @@ -0,0 +1,53 @@ +# Copyright (c) 2015-2017, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +ifeq ($(filter proper,$(DEPS) $(TEST_DEPS)),proper) +.PHONY: proper + +# Targets. + +tests:: proper + +define proper_check.erl + code:add_pathsa(["$(call core_native_path,$(CURDIR)/ebin)", "$(call core_native_path,$(DEPS_DIR)/*/ebin)"]), + Module = fun(M) -> + [true] =:= lists:usort([ + case atom_to_list(F) of + "prop_" ++ _ -> + io:format("Testing ~p:~p/0~n", [M, F]), + proper:quickcheck(M:F()); + _ -> + true + end + || {F, 0} <- M:module_info(exports)]) + end, + try + case $(1) of + all -> [true] =:= lists:usort([Module(M) || M <- [$(call comma_list,$(3))]]); + module -> Module($(2)); + function -> proper:quickcheck($(2)) + end + of + true -> halt(0); + _ -> halt(1) + catch error:undef -> + io:format("Undefined property or module?~n~p~n", [erlang:get_stacktrace()]), + halt(0) + end. +endef + +ifdef t +ifeq (,$(findstring :,$(t))) +proper: test-build + $(verbose) $(call erlang,$(call proper_check.erl,module,$(t))) +else +proper: test-build + $(verbose) echo Testing $(t)/0 + $(verbose) $(call erlang,$(call proper_check.erl,function,$(t)())) +endif +else +proper: test-build + $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename $(wildcard ebin/*.beam)))))) + $(gen_verbose) $(call erlang,$(call proper_check.erl,all,undefined,$(MODULES))) +endif +endif diff --git a/plugins/triq.mk b/plugins/triq.mk index 784f2e2..09443b5 100644 --- a/plugins/triq.mk +++ b/plugins/triq.mk @@ -20,7 +20,7 @@ define triq_check.erl true -> halt(0); _ -> halt(1) catch error:undef -> - io:format("Undefined property or module~n"), + io:format("Undefined property or module?~n~p~n", [erlang:get_stacktrace()]), halt(0) end. endef -- cgit v1.2.3