Selaa lähdekoodia

chore(test): make app-ct run easier

Zaiming Shi 4 vuotta sitten
vanhempi
commit
45dfc8a2fa
4 muutettua tiedostoa jossa 43 lisäystä ja 7 poistoa
  1. 10 0
      Makefile
  2. 2 7
      README.md
  3. 18 0
      scripts/find-apps.sh
  4. 13 0
      scripts/find-suites.sh

+ 10 - 0
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

+ 2 - 7
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
 ```

+ 18 - 0
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

+ 13 - 0
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' ','