chore(test): make app-ct run easier

This commit is contained in:
Zaiming Shi 2021-03-20 10:57:56 +01:00 committed by Zaiming (Stone) Shi
parent 7ea69f56be
commit 45dfc8a2fa
4 changed files with 43 additions and 7 deletions

View File

@ -46,6 +46,16 @@ proper: $(REBAR)
ct: $(REBAR) ct: $(REBAR)
@ENABLE_COVER_COMPILE=1 $(REBAR) ct --name 'test@127.0.0.1' -c -v @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 .PHONY: cover
cover: $(REBAR) cover: $(REBAR)
@ENABLE_COVER_COMPILE=1 $(REBAR) cover @ENABLE_COVER_COMPILE=1 $(REBAR) cover

View File

@ -89,17 +89,12 @@ make eunit ct
### To run subset of the common tests ### To run subset of the common tests
examples Examples
```bash ```bash
./rebar3 ct --name 'test@127.0.0.1' -c -v --dir test,apps/emqx_sn,apps/emqx_coap make apps/emqx_bridge_mqtt-ct
./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
``` ```
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 ### Dialyzer
##### To Analyze all the apps ##### To Analyze all the apps
``` ```

18
scripts/find-apps.sh Executable file
View File

@ -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

13
scripts/find-suites.sh Executable file
View File

@ -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' ','