From 45dfc8a2fa5b1ee1035d03f3b40846bca92a4251 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Sat, 20 Mar 2021 10:57:56 +0100 Subject: [PATCH] chore(test): make app-ct run easier --- Makefile | 10 ++++++++++ README.md | 9 ++------- scripts/find-apps.sh | 18 ++++++++++++++++++ scripts/find-suites.sh | 13 +++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100755 scripts/find-apps.sh create mode 100755 scripts/find-suites.sh diff --git a/Makefile b/Makefile index 85fd7bf6d..38251043c 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,16 @@ proper: $(REBAR) ct: $(REBAR) @ENABLE_COVER_COMPILE=1 $(REBAR) ct --name 'test@127.0.0.1' -c -v +APPS=$(shell $(CURDIR)/scripts/find-apps.sh) + +## app/name-ct targets are intended for local tests hence cover is not enabled +.PHONY: $(APPS:%=%-ct) +define gen-app-ct-target +$1-ct: + $(REBAR) ct --name 'test@127.0.0.1' -v --suite $(shell $(CURDIR)/scripts/find-suites.sh $1) +endef +$(foreach app,$(APPS),$(eval $(call gen-app-ct-target,$(app)))) + .PHONY: cover cover: $(REBAR) @ENABLE_COVER_COMPILE=1 $(REBAR) cover diff --git a/README.md b/README.md index af683f881..cf672b8bb 100644 --- a/README.md +++ b/README.md @@ -89,17 +89,12 @@ make eunit ct ### To run subset of the common tests -examples +Examples ```bash -./rebar3 ct --name 'test@127.0.0.1' -c -v --dir test,apps/emqx_sn,apps/emqx_coap -./rebar3 ct --name 'test@127.0.0.1' -c -v --dir apps/emqx_auth_mnesi --suite emqx_acl_mnesia_SUITE -./rebar3 ct --name 'test@127.0.0.1' -c -v --dir apps/emqx_auth_mnesi --suite emqx_acl_mnesia_SUITE --case t_rest_api +make apps/emqx_bridge_mqtt-ct ``` -NOTE: Do *NOT* use full (relative) path to SUITE files like this `--suite apps/emqx_auth_mnesia/test/emqx_acl_mnesia_SUITE.erl`, -because it will lead to a full copy of `apps` dir into `_buid/test/lib/emqx`. - ### Dialyzer ##### To Analyze all the apps ``` diff --git a/scripts/find-apps.sh b/scripts/find-apps.sh new file mode 100755 index 000000000..ebb06f1ac --- /dev/null +++ b/scripts/find-apps.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# ensure dir +cd -P -- "$(dirname -- "$0")/.." + +find_app() { + local appdir="$1" + find "${appdir}/" -mindepth 1 -maxdepth 1 -type d +} + +find_app 'apps' +if [ -f 'EMQX_ENTERPRISE' ]; then + find_app 'lib-ee' +else + find_app 'lib-ce' +fi diff --git a/scripts/find-suites.sh b/scripts/find-suites.sh new file mode 100755 index 000000000..66296b758 --- /dev/null +++ b/scripts/find-suites.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +## this script prints out all test/*_SUITE.erl files of a given app, +## file names are separated by comma for rebar3 ct's `--suite` option + +set -euo pipefail + +# ensure dir +cd -P -- "$(dirname -- "$0")/.." + +APPDIR="$1" + +find "${APPDIR}/test" -name "*_SUITE.erl" | tr -d '\r' | tr '\n' ','