Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests

Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests

Date: Tue, 28 Jun 2011 12:22:57 -0400

To: Dmitry Kurochkin

Cc: notmuch@notmuchmail.org

From: Austin Clements


Quoth myself on Jun 27 at 11:49 pm:
> Quoth Dmitry Kurochkin on Jun 28 at  5:03 am:
> EMACSDONE=$TEST_DIRECTORY/emacsdone
> mkfifo $EMACSDONE
> coproc emacs --batch --eval '(while t (eval (read)) (write-region "\n" nil "'$EMACSDONE'" t 0))'
> EMACSFD=${COPROC[1]}
> 
> test_emacs() {
>     echo "$1" >&$EMACSFD
>     read <$EMACSDONE
> }
> 
> test_emacs '(sleep-for 2)'
> test_emacs '(message "Hi")'
> 
> echo '(kill-emacs)' >&$EMACSFD

Oops, got a little overzealous with TEST_DIRECTORY.  For reference,
the pipe should, of course, have gone in the current directory (or
TMP_DIRECTORY).

mkfifo emacsdone
coproc emacs --batch --eval '(while t (eval (read)) (write-region "\n" nil "emacsdone" t 0))'
EMACSFD=${COPROC[1]}

test_emacs() {
    echo "$1" >&$EMACSFD
    read < emacsdone
}


(I don't really see how that could be either more shell code or more
elisp code than using emacsclient plus cleanup code [nor why it
matters for five lines of code], but I'm probably missing something.)

Thread: