From 7ee4e7958acf0f0956bd64023ecb1731b2824b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 10 Jan 2015 18:25:22 +0100 Subject: Introduce test builds and unify testing tools interface The general idea is that erlang.mk now keeps track of what kind of build it generated. A test build is valid for all subsequent test target invocations. A normal build is only valid for itself and releases. This rework adds the ability to specify deps to eunit. The EUNIT_DIR variable is gone in favor of a more global TEST_DIR. The tests-ct target got renamed to ct and documented. Many more minor changes were done during the course of testing these changes. --- plugins/eunit.mk | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'plugins/eunit.mk') diff --git a/plugins/eunit.mk b/plugins/eunit.mk index 1b83a0f..ae132ac 100644 --- a/plugins/eunit.mk +++ b/plugins/eunit.mk @@ -1,25 +1,20 @@ # Copyright (c) 2014, Enrique Fernandez # This file is contributed to erlang.mk and subject to the terms of the ISC License. -.PHONY: help-eunit build-eunit eunit distclean-eunit +.PHONY: eunit # Configuration -EUNIT_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard -DTEST=1 -DEXTRA=1 - -EUNIT_DIR ?= -EUNIT_DIRS = $(sort $(EUNIT_DIR) ebin) - -ifeq ($(strip $(EUNIT_DIR)),) +ifeq ($(strip $(TEST_DIR)),) TAGGED_EUNIT_TESTS = {dir,"ebin"} else -# All modules in EUNIT_DIR -EUNIT_DIR_MODS = $(notdir $(basename $(shell find $(EUNIT_DIR) -type f -name *.beam))) +# All modules in TEST_DIR +TEST_DIR_MODS = $(notdir $(basename $(shell find $(TEST_DIR) -type f -name *.beam))) # All modules in 'ebin' EUNIT_EBIN_MODS = $(notdir $(basename $(shell find ebin -type f -name *.beam))) -# Only those modules in EUNIT_DIR with no matching module in 'ebin'. +# Only those modules in TEST_DIR with no matching module in 'ebin'. # This is done to avoid some tests being executed twice. -EUNIT_MODS = $(filter-out $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(EUNIT_DIR_MODS)) +EUNIT_MODS = $(filter-out $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(TEST_DIR_MODS)) TAGGED_EUNIT_TESTS = {dir,"ebin"} $(foreach mod,$(EUNIT_MODS),$(shell echo $(mod) | sed -e 's/\(.*\)/{module,\1}/g')) endif @@ -33,38 +28,19 @@ endef # Core targets. -help:: help-eunit - tests:: eunit -clean:: clean-eunit +help:: + @printf "%s\n" "" \ + "EUnit targets:" \ + " eunit Run all the EUnit tests for this project" # Plugin-specific targets. EUNIT_RUN = $(ERL) \ - -no_auto_compile \ - -pa $(realpath $(EUNIT_DIR)) $(DEPS_DIR)/*/ebin \ - -pz $(realpath ebin) \ + -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin \ + -pz ebin \ -eval 'case eunit:test([$(call str-join,$(TAGGED_EUNIT_TESTS))], [$(EUNIT_OPTS)]) of ok -> halt(0); error -> halt(1) end.' -help-eunit: - @printf "%s\n" "" \ - "EUnit targets:" \ - " eunit Run all the EUnit tests for this project" - -ifeq ($(strip $(EUNIT_DIR)),) -build-eunit: -else ifeq ($(strip $(EUNIT_DIR)),ebin) -build-eunit: -else -build-eunit: - $(gen_verbose) erlc -v $(EUNIT_ERLC_OPTS) -I include/ -o $(EUNIT_DIR) \ - $(wildcard $(EUNIT_DIR)/*.erl $(EUNIT_DIR)/*/*.erl) -pa ebin/ -endif - -eunit: ERLC_OPTS = $(EUNIT_ERLC_OPTS) -eunit: clean deps app build-eunit +eunit: test-build $(gen_verbose) $(EUNIT_RUN) - -clean-eunit: - $(gen_verbose) $(foreach dir,$(EUNIT_DIRS),rm -rf $(dir)/*.beam) -- cgit v1.2.3