aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/Makefile25
-rw-r--r--test/plugin_relx.mk13
2 files changed, 31 insertions, 7 deletions
diff --git a/test/Makefile b/test/Makefile
index 39973ce..b7e8724 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -50,6 +50,31 @@ else
SLEEP =
endif
+# In some cases it is more appropriate to wait until a command succeeds or fails.
+# These functions run the given command every second and gives up after 10 tries.
+
+define wait_for_success
+ count=10; \
+ until [ $$count = 0 ] || $1; do \
+ count=`expr $$count - 1`; \
+ sleep 1; \
+ done; \
+ if [ $$count = 0 ]; then \
+ false; \
+ fi
+endef
+
+define wait_for_failure
+ count=10; \
+ while [ $$count != 0 ] && $1; do \
+ count=`expr $$count - 1`; \
+ sleep 1; \
+ done; \
+ if [ $$count = 0 ]; then \
+ false; \
+ fi
+endef
+
# OTP master, for downloading files for testing.
OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master
diff --git a/test/plugin_relx.mk b/test/plugin_relx.mk
index c65e672..2771e8f 100644
--- a/test/plugin_relx.mk
+++ b/test/plugin_relx.mk
@@ -301,28 +301,27 @@ ifeq ($(PLATFORM),msys2)
$t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) install
endif
$t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) start
- $t sleep 1
$i "Ping the release"
- $t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping
+ $t $(call wait_for_success,$(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping)
$i "Stop the release"
$t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) stop
- $t sleep 1
ifeq ($(PLATFORM),msys2)
+ $t sleep 1
$t $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) uninstall
endif
- $i "Check that there's no erl_crash.dump file"
- $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump
-
ifneq ($(PLATFORM),msys2)
# The script will not return false on Windows when the ping fails.
# It sometimes also gets stuck. So we just skip the ping for now.
$i "Check that further pings get no replies"
- $t ! $(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping
+ $t $(call wait_for_failure,$(APP)/_rel/$(APP)_release/bin/$(APP)_release$(RELX_REL_EXT) ping)
endif
+ $i "Check that there's no erl_crash.dump file"
+ $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump
+
relx-tar: init
$i "Bootstrap a new release named $(APP)"