[PATCH 2/2] test/test-lib.sh: launch smtp-dummy with --background and finally kill(1) it.

Tomi Ollila tomi.ollila at iki.fi
Mon Dec 12 14:29:56 PST 2011


Take the new --background option of smtp-dummy to use so that it is known
there is smtpd listener ready when it is needed. As the smtp-dummy instance
is no longer child process of the script sending SIGKILL to it is the only
way to make sure the instance exits when required.
---
 test/test-lib.sh |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6be93fe..a857afe 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -382,8 +382,9 @@ emacs_deliver_message ()
     shift 2
     # before we can send a message, we have to prepare the FCC maildir
     mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}
-    $TEST_DIRECTORY/smtp-dummy sent_message &
-    smtp_dummy_pid=$!
+
+    smtp_dummy_pid=$($TEST_DIRECTORY/smtp-dummy --background sent_message) \
+	|| return
     test_emacs \
 	"(let ((message-send-mail-function 'message-smtpmail-send-it)
 	       (smtpmail-smtp-server \"localhost\")
@@ -398,9 +399,10 @@ emacs_deliver_message ()
 	   (insert \"${body}\")
 	   $@
 	   (message-send-and-exit))"
-    # opportunistically quit smtp-dummy in case above fails.
-    { echo QUIT > /dev/tcp/localhost/25025; } 2>/dev/null
-    wait ${smtp_dummy_pid}
+    # Cannot wait, not our child. In case message was sent properly, client
+    # waits for confirmation before exiting and resuming control here; therefore
+    # making sure that server exits by sending (KILL) signal to it is safe.
+    kill -9 ${smtp_dummy_pid}
     notmuch new >/dev/null
 }
 
-- 
1.7.7.3



More information about the notmuch mailing list