Просмотр исходного кода

build(test): add proper checking targets for each application

JianBo He 4 лет назад
Родитель
Сommit
4f6216b812
3 измененных файлов с 26 добавлено и 2 удалено
  1. 9 1
      Makefile
  2. 16 0
      scripts/find-props.sh
  3. 1 1
      scripts/find-suites.sh

+ 9 - 1
Makefile

@@ -40,7 +40,7 @@ eunit: $(REBAR)
 
 .PHONY: proper
 proper: $(REBAR)
-	@ENABLE_COVER_COMPILE=1 $(REBAR) as test proper -d test/props -c
+	@ENABLE_COVER_COMPILE=1 $(REBAR) proper -d test/props -c
 
 .PHONY: ct
 ct: $(REBAR)
@@ -56,6 +56,14 @@ $1-ct:
 endef
 $(foreach app,$(APPS),$(eval $(call gen-app-ct-target,$(app))))
 
+## apps/name-prop targets
+.PHONY: $(APPS:%=%-prop)
+define gen-app-prop-target
+$1-prop:
+	$(REBAR) proper -d test/props -v -m $(shell $(CURDIR)/scripts/find-props.sh $1)
+endef
+$(foreach app,$(APPS),$(eval $(call gen-app-prop-target,$(app))))
+
 .PHONY: cover
 cover: $(REBAR)
 	@ENABLE_COVER_COMPILE=1 $(REBAR) cover

+ 16 - 0
scripts/find-props.sh

@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+## this script prints out all test/props/prop_*.erl files of a given app,
+## file names are separated by comma for proper's `-m` option
+
+set -euo pipefail
+
+# ensure dir
+cd -P -- "$(dirname -- "$0")/.."
+
+BASEDIR="."
+if [ "$1" != "emqx" ]; then
+    BASEDIR="$1"
+fi
+
+find "${BASEDIR}/test/props" -name "prop_*.erl" 2>/dev/null | xargs -I{} basename {} .erl | xargs | tr ' ' ','

+ 1 - 1
scripts/find-suites.sh

@@ -12,4 +12,4 @@ TESTDIR="test"
 if [ "$1" != "emqx" ]; then
     TESTDIR="$1/test"
 fi
-find "${TESTDIR}" -name "*_SUITE.erl" | tr -d '\r' | tr '\n' ','
+find "${TESTDIR}" -name "*_SUITE.erl" 2>/dev/null | xargs | tr ' ' ','