From 72a61573442c5a74818c9cdefb94f568250b534a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 10 Jan 2015 21:22:50 +0100 Subject: Add triq plugin --- README.md | 27 ++++++++++++++++++++++++--- build.config | 1 + erlang.mk | 30 ++++++++++++++++++++++++++++++ plugins/triq.mk | 29 +++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 plugins/triq.mk diff --git a/README.md b/README.md index a2ee878..d9717f6 100644 --- a/README.md +++ b/README.md @@ -450,9 +450,8 @@ EUnit plugin This plugin is available by default. It adds the following target: -`eunit` which runs all the EUnit tests found in `ebin` and -any of the additional EUnit directories specified in -`TEST_DIR`. +`eunit` which runs all the EUnit tests found in `ebin` or +the test directory specified in `TEST_DIR`. `EUNIT_OPTS` can be used to specify EUnit-specific options (e.g. `verbose`) that will be used when calling @@ -499,6 +498,28 @@ For more information please see `erl -man erl`. `SHELL_PATH` adds paths to the shell's library search path. By default this option sets the paths to `-pa ../$(PROJECT)/ebin $(DEPS_DIR)/*/ebin`. +Triq plugin +----------- + +This plugin is available by default. It adds the following +target: + +`triq` will check all the properties found in `ebin` or +the test directory specified in `TEST_DIR`. + +You can use the `t` variable to give a specific module +or function to run, for example: + +``` bash +$ make triq t=cow_http_hd +``` + +Or: + +``` bash +$ make triq t=cow_http_hd:prop_parse_accept +``` + Contributing ------------ diff --git a/build.config b/build.config index 48ac7e1..7e60d80 100644 --- a/build.config +++ b/build.config @@ -21,3 +21,4 @@ plugins/escript plugins/eunit plugins/relx plugins/shell +plugins/triq diff --git a/erlang.mk b/erlang.mk index 61f8ad5..b943618 100644 --- a/erlang.mk +++ b/erlang.mk @@ -1185,3 +1185,33 @@ build-shell-deps: $(ALL_SHELL_DEPS_DIRS) shell: build-shell-deps $(gen_verbose) erl $(SHELL_PATH) $(SHELL_OPTS) + +# Copyright (c) 2015, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: triq + +# Targets. + +tests:: triq + +define triq_run +$(ERL) -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin \ + -eval "try $(1) of true -> halt(0); _ -> halt(1) catch error:undef -> io:format(\"Undefined property or module~n\"), halt() end." +endef + +ifdef t +ifeq (,$(findstring :,$(t))) +triq: test-build + @$(call triq_run,triq:check($(t))) +else +triq: test-build + @echo Testing $(t)/0 + @$(call triq_run,triq:check($(t)())) +endif +else +triq: test-build + $(eval MODULES := $(shell find ebin -type f -name \*.beam \ + | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//')) + $(gen_verbose) $(call triq_run,[true] =:= lists:usort([triq:check(M) || M <- [$(MODULES)]])) +endif diff --git a/plugins/triq.mk b/plugins/triq.mk new file mode 100644 index 0000000..8a77c91 --- /dev/null +++ b/plugins/triq.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2015, Loïc Hoguin +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: triq + +# Targets. + +tests:: triq + +define triq_run +$(ERL) -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin \ + -eval "try $(1) of true -> halt(0); _ -> halt(1) catch error:undef -> io:format(\"Undefined property or module~n\"), halt() end." +endef + +ifdef t +ifeq (,$(findstring :,$(t))) +triq: test-build + @$(call triq_run,triq:check($(t))) +else +triq: test-build + @echo Testing $(t)/0 + @$(call triq_run,triq:check($(t)())) +endif +else +triq: test-build + $(eval MODULES := $(shell find ebin -type f -name \*.beam \ + | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//')) + $(gen_verbose) $(call triq_run,[true] =:= lists:usort([triq:check(M) || M <- [$(MODULES)]])) +endif -- cgit v1.2.3