diff options
author | Tomi Ollila <too@iki.fi> | 2012-09-18 17:23:02 +0300 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2012-10-20 17:46:11 -0300 |
commit | b7f7b573e4bf3d00d9e887bc1aee264722d22778 (patch) | |
tree | ebdfac5435ea3b0f4e8fd52fc203d51062cb3607 /test/test-lib.sh | |
parent | d894887c94c67860af817239bb1ce3b0360ec3e0 (diff) |
test/test-lib.sh: take the --background feature in smtp-dummy into use
The use of --background option (instead of shell '&') ensures that
smtp-dummy is listening its server socket until execution of shell
script can continue, thus the client will always have socket where
to connect.
smtp-dummy outputs smtp_dummy_pid variable in shell assignment format;
eval'ing that output makes that variable available for the shell.
As the smtp-dummy instance is no longer child process of the script
the SIGKILL signal sent to it will ensure it is going away in case
the mail sender fails to connect to smtp-dummy.
Diffstat (limited to 'test/test-lib.sh')
-rw-r--r-- | test/test-lib.sh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index 568e89f1..2f7d6cd1 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -403,8 +403,11 @@ 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=$! + # eval'ing smtp-dummy --background will set smtp_dummy_pid + smtp_dummy_pid= + eval `$TEST_DIRECTORY/smtp-dummy --background sent_message` + test -n "$smtp_dummy_pid" || return 1 + test_emacs \ "(let ((message-send-mail-function 'message-smtpmail-send-it) (smtpmail-smtp-server \"localhost\") @@ -419,9 +422,11 @@ 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} + + # 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 } |