aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-11-26 23:46:31 +0100
committerLoïc Hoguin <[email protected]>2018-11-26 23:46:31 +0100
commitf07636e66759ecdaff4ee4e9097ecbf88eb6b217 (patch)
treef3dea02e4a3d0bc9f77ff83d4381eb2a4358e816
parent2277830e3f2b5b8c71438c6c7f991037d04949ba (diff)
downloaderlang.mk-f07636e66759ecdaff4ee4e9097ecbf88eb6b217.tar.gz
erlang.mk-f07636e66759ecdaff4ee4e9097ecbf88eb6b217.tar.bz2
erlang.mk-f07636e66759ecdaff4ee4e9097ecbf88eb6b217.zip
Allow running test cases without groups in CT
-rw-r--r--Makefile2
-rw-r--r--doc/src/guide/common_test.asciidoc6
-rw-r--r--plugins/ct.mk10
-rw-r--r--test/plugin_ct.mk19
4 files changed, 33 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 8f5af8a..89015a0 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,7 @@ check:
else
ifdef c
check:
- $(MAKE) -C test $c
+ $(MAKE) -C test $c c=
else
check:
$(MAKE) -C test
diff --git a/doc/src/guide/common_test.asciidoc b/doc/src/guide/common_test.asciidoc
index f8f0de3..993bb8c 100644
--- a/doc/src/guide/common_test.asciidoc
+++ b/doc/src/guide/common_test.asciidoc
@@ -93,5 +93,11 @@ as a dependency, you can run the following directly:
[source,bash]
$ make -C deps/cowboy ct-http t=http_compress
+The variable `c` can be used to run a specific test when
+the test suite does not group test cases:
+
+[source,bash]
+$ make ct-http c=headers_dupe
+
Finally, xref:coverage[code coverage] is available,
but covered in its own chapter.
diff --git a/plugins/ct.mk b/plugins/ct.mk
index b9199e9..3db994d 100644
--- a/plugins/ct.mk
+++ b/plugins/ct.mk
@@ -62,15 +62,19 @@ $(foreach app,$(ALL_APPS_DIRS),$(eval $(call ct_app_target,$(app))))
apps-ct: $(addprefix apps-ct-,$(ALL_APPS_DIRS))
endif
-ifndef t
-CT_EXTRA =
-else
+ifdef t
ifeq (,$(findstring :,$t))
CT_EXTRA = -group $t
else
t_words = $(subst :, ,$t)
CT_EXTRA = -group $(firstword $(t_words)) -case $(lastword $(t_words))
endif
+else
+ifdef c
+CT_EXTRA = -case $c
+else
+CT_EXTRA =
+endif
endif
define ct_suite_target
diff --git a/test/plugin_ct.mk b/test/plugin_ct.mk
index e58f01b..0aaf1ea 100644
--- a/test/plugin_ct.mk
+++ b/test/plugin_ct.mk
@@ -151,6 +151,25 @@ ct-case: build clean
$i "Check that we can run Common Test on a specific test case"
$t $(MAKE) -C $(APP) ct-$(APP) t=mygroup:ok $v
+ct-case-without-group: build clean
+
+ $i "Bootstrap a new OTP application named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
+
+ $i "Generate a Common Test suite with two cases that are not part of any group"
+ $t mkdir $(APP)/test
+ $t printf "%s\n" \
+ "-module($(APP)_SUITE)." \
+ "-export([all/0, ok/1, bad/1])." \
+ "all() -> [ok, bad]." \
+ "ok(_) -> ok." \
+ "bad(_) -> throw(fail)." > $(APP)/test/$(APP)_SUITE.erl
+
+ $i "Check that we can run Common Test on a specific test case"
+ $t $(MAKE) -C $(APP) ct-$(APP) c=ok $v
+
ct-check: build clean
$i "Bootstrap a new OTP application named $(APP)"