aboutsummaryrefslogtreecommitdiffstats
path: root/test/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'test/Makefile')
-rw-r--r--test/Makefile149
1 files changed, 18 insertions, 131 deletions
diff --git a/test/Makefile b/test/Makefile
index 4779c9f..f01e3ab 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -12,8 +12,7 @@ endif
# Temporary application name, taken from rule name.
-APP = $(subst -,_,$@)
-APP_TO_CLEAN = $(subst -,_,$(patsubst clean-%,%,$@))
+APP = test_$(subst -,_,$@)
# Erlang, quickly!
@@ -61,6 +60,7 @@ OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master
# V=1: Show test commands.
# V=2: Also show normal Erlang.mk output.
# V=3: Also show verbose Erlang.mk output.
+# V=4: Also show a trace of each command after expansion.
V ?= 0
@@ -82,7 +82,7 @@ else ifeq ($V,2)
i = @echo == $@:
else
t =
- v = V=1
+ v = V=$(shell echo $$(($(V)-2)))
i = @echo == $@:
endif
@@ -92,8 +92,8 @@ endif
all:: core
-clean:: clean-core
- $t rm -rf erl_crash.dump packages/
+clean::
+ $t rm -rf erl_crash.dump packages/ test_*/
build:
$i "Generate a bleeding edge Erlang.mk"
@@ -101,11 +101,10 @@ build:
# Core.
-.PHONY: core clean-core
+.PHONY: core
define include_core
core:: core-$1
-clean-core:: clean-core-$1
include core_$1.mk
@@ -117,7 +116,6 @@ $(eval $(foreach t,$(patsubst %.mk,%,$(patsubst core_%,%,$(wildcard core_*.mk)))
define include_plugin
all:: $1
-clean:: clean-$1
include plugin_$1.mk
@@ -128,14 +126,10 @@ $(eval $(foreach t,$(patsubst %.mk,%,$(patsubst plugin_%,%,$(wildcard plugin_*.m
# Tests that don't easily fit into other categories.
core:: core-clean-crash-dump core-distclean-tmp core-help
-clean-core:: clean-core-clean-crash-dump clean-core-distclean-tmp clean-core-help
-.PHONY: core-clean-crash-dump core-distclean-tmp core-help clean-core-clean-crash-dump clean-core-distclean-tmp clean-core-help
+.PHONY: core-clean-crash-dump core-distclean-tmp core-help
-clean-core-clean-crash-dump clean-core-distclean-tmp clean-core-help:
- $t rm -rf $(APP_TO_CLEAN)/
-
-core-clean-crash-dump: build clean-core-clean-crash-dump
+core-clean-crash-dump: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
@@ -151,7 +145,7 @@ core-clean-crash-dump: build clean-core-clean-crash-dump
$i "Check that the crash dump is removed"
$t test ! -e $(APP)/erl_crash.dump
-core-distclean-tmp: build clean-core-distclean-tmp
+core-distclean-tmp: build clean
$i "Bootstrap a new OTP application named $(APP)"
$t mkdir $(APP)/
@@ -167,7 +161,7 @@ core-distclean-tmp: build clean-core-distclean-tmp
$i "Check that .erlang.mk directory got removed"
$t test ! -e $(APP)/.erlang.mk
-core-help: build clean-core-help
+core-help: build clean
$i "Bootstrap a new OTP library named $(APP)"
$t mkdir $(APP)/
@@ -180,13 +174,14 @@ core-help: build clean-core-help
# Packages.
PACKAGES = $(foreach pkg,$(sort $(wildcard ../index/*.mk)),$(notdir $(basename $(pkg))))
+EXCLUDE_FROM_CHECK = [rabbitmq_codegen]
packages: $(addprefix pkg-,$(PACKAGES))
define pkg_target
.PHONY: pkg-$1
-pkg-$1: clean build
+pkg-$1: build clean
# Make sure $@ is defined inside the define.
$(eval @ = pkg-$1)
@@ -202,14 +197,6 @@ pkg-$1: clean build
$i "Add package $1 to the Makefile"
$t perl -ni.bak -e 'print;if ($$$$.==1) {print "DEPS = $1\n"}' packages/$1_pkg/Makefile
- $(if $(filter amqp_client,$1),
- $i "Set RABBITMQ_CLIENT_PATCH"
- $(eval PATCHES := RABBITMQ_CLIENT_PATCH=1))
-
- $(if $(filter rabbit,$1),
- $i "Set RABBITMQ_SERVER_PATCH"
- $(eval PATCHES := RABBITMQ_SERVER_PATCH=1))
-
$i "Compile package $1"
$t if ! ( cd packages/$1_pkg/ && $(MAKE) $(PATCHES) $v ); then \
echo "$1: compile error" >> packages/errors.log; \
@@ -224,8 +211,9 @@ pkg-$1: clean build
$i "Check that all applications and their modules can be loaded"
$t if ! ( cd packages/$1_pkg/ && $(ERL) -pa deps/*/ebin/ -eval " \
- Apps = [list_to_atom(App) || \"deps/\" ++ App \
+ Apps0 = [list_to_atom(App) || \"deps/\" ++ App \
<- filelib:wildcard(\"deps/*\")], \
+ Apps = [App || App <- Apps0, not lists:member(App, $(EXCLUDE_FROM_CHECK))], \
[begin \
io:format(\"Loading application ~p~n\", [App]), \
case application:load(App) of \
@@ -257,8 +245,9 @@ pkg-$1: clean build
$i "Check that all applications and their modules can still be loaded"
$t if ! ( cd packages/$1_pkg/ && $(ERL) -pa deps/*/ebin/ -eval " \
- Apps = [list_to_atom(App) || \"deps/\" ++ App \
+ Apps0 = [list_to_atom(App) || \"deps/\" ++ App \
<- filelib:wildcard(\"deps/*\")], \
+ Apps = [App || App <- Apps0, not lists:member(App, $(EXCLUDE_FROM_CHECK))], \
[begin \
io:format(\"Loading application ~p~n\", [App]), \
case application:load(App) of \
@@ -314,92 +303,13 @@ endef
# The following tests are slowly being converted.
# Do NOT use -j with legacy tests.
-.PHONY: legacy clean-legacy ct eunit tests-cover docs
+.PHONY: legacy clean-legacy tests-cover
-legacy: clean-legacy ct eunit tests-cover docs pkgs
+legacy: clean-legacy tests-cover
clean-legacy:
$t rm -rf app1
-ct: app1
- $i "ct: Testing ct and related targets."
- $i "Setting up test suite."
- $t mkdir -p app1/test
- $t printf "%s\n" \
- "-module(m_SUITE)." \
- "-export([all/0, testcase1/1])." \
- "all() -> [testcase1]." \
- "testcase1(_) -> 2 = m:succ(1)." \
- > app1/test/m_SUITE.erl
- $t $(MAKE) -C app1 ct $v
- $i "Checking files created by '$(MAKE) ct'."
- $t [ -e app1/test/m_SUITE.beam ]
- $t [ -e app1/ebin/m.beam ]
- $t [ -e app1/logs ]
- $i "Checking that '$(MAKE) clean' does not delete logs."
- $t $(MAKE) -C app1 clean $v
- $t [ -e app1/logs ]
- $i "Testing target 'ct-mysuite' where mysuite_SUITE is a test suite."
- $t $(MAKE) -C app1 ct-m $v
- $i "Checking that '$(MAKE) ct' returns non-zero for a failing suite."
- $t printf "%s\n" \
- "-module(failing_SUITE)." \
- "-export([all/0, testcase1/1])." \
- "all() -> [testcase1]." \
- "testcase1(_) -> 42 = m:succ(1)." \
- > app1/test/failing_SUITE.erl
- $t ! $(MAKE) -C app1 ct-failing $v
- $i "Checking that '$(MAKE) distclean-ct' deletes logs."
- $t $(MAKE) -C app1 distclean-ct $v
- $t [ ! -e app1/logs ]
- $t [ -e app1/ebin/m.beam ]
- $i "Cleaning up test data."
- $t rm -rf app1/test
- $i "Test 'ct' passed."
-
-eunit: app1
- $i "eunit: Testing the 'eunit' target."
- $i "Running eunit test case inside module src/t.erl"
- $t $(call create-module-t)
- $t $(MAKE) -C app1 distclean $v
- $t $(MAKE) -C app1 eunit $v
- $i "Checking that the eunit test in module t."
- $t echo t | cmp app1/test-eunit.log -
- $t rm app1/test-eunit.log
- $i "Running eunit tests in a separate directory."
- $t mkdir -p app1/eunit
- $t printf '%s\n' \
- '-module(t_tests).' \
- '-include_lib("eunit/include/eunit.hrl").' \
- 'succ_test() ->' \
- ' ?assertEqual(2, t:succ(1)),' \
- ' os:cmd("echo t_tests >> test-eunit.log").' \
- > app1/eunit/t_tests.erl
- $t printf '%s\n' \
- '-module(x_tests).' \
- '-include_lib("eunit/include/eunit.hrl").' \
- 'succ_test() ->' \
- ' ?assertEqual(2, t:succ(1)),' \
- ' os:cmd("echo x_tests >> test-eunit.log").' \
- > app1/eunit/x_tests.erl
- $t $(MAKE) -C app1 distclean TEST_DIR=eunit $v
- $t $(MAKE) -C app1 eunit TEST_DIR=eunit $v
- $i "Checking that '$(MAKE) eunit' didn't run the tests in t_tests twice, etc."
- $t printf "%s\n" t t_tests x_tests | cmp app1/test-eunit.log -
- $t rm app1/test-eunit.log
- $i "Checking that '$(MAKE) eunit' returns non-zero for a failing test."
- $t rm -f app1/eunit/*
- $t printf "%s\n" \
- "-module(t_tests)." \
- '-include_lib("eunit/include/eunit.hrl").' \
- "succ_test() ->" \
- " ?assertEqual(42, t:succ(1))." \
- > app1/eunit/t_tests.erl
- $t $(MAKE) -C app1 distclean TEST_DIR=eunit $v
- $t ! $(MAKE) -C app1 eunit TEST_DIR=eunit $v
- $t rm -rf app1/eunit app1/src/t.erl app1/test-eunit.log
- $i "Test 'eunit' passed."
-
# TODO: do coverage for 'tests' instead of 'eunit ct' when triq is fixed
tests-cover: app1
$i "tests-cover: Testing 'eunit' and 'ct' with COVER=1"
@@ -435,29 +345,6 @@ tests-cover: app1
$t $(MAKE) -C app1 clean $v
$i "Test 'tests-cover' passed."
-docs: app1
- $i "docs: Testing EDoc including DOC_DEPS."
- $t printf "%s\n" \
- "PROJECT = app1" \
- "DOC_DEPS = edown" \
- "dep_edown = git https://github.com/uwiger/edown.git 0.7" \
- "EDOC_OPTS = {doclet, edown_doclet}" \
- "include erlang.mk" \
- "distclean:: distclean-doc-md" \
- "distclean-doc-md:" \
- " rm -rf doc/*.md" \
- > app1/Makefile-doc
- $i "Downloading doc deps (edown) and building docs."
- $t $(MAKE) -C app1 -f Makefile-doc docs $v
- $i "Checking that '$(MAKE) docs' using edown generated a markdown file."
- $t [ -e app1/doc/m.md ]
- $i "Checking that '$(MAKE) distclean' deletes all generated doc files."
- $t $(MAKE) -C app1 -f Makefile-doc distclean $v
- $t [ "`ls app1/doc/`" = "" ]
- $i "Cleaning up test data."
- $t rm app1/Makefile-doc
- $i "Test 'docs' passed."
-
define app1_setup
$i "Setting up app."
$t mkdir -p app1