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

Dmitry Kurochkin dmitry.kurochkin at gmail.com
Tue Jun 28 09:42:42 PDT 2011


On Tue, 28 Jun 2011 12:22:57 -0400, Austin Clements <amdragon at MIT.EDU> wrote:
> 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.)

Well, it may not be less code if you count lines.  It is just IMHO, but
it shell code in case of emacsclient is simpler (no fifo, no coproc),
cleanup is the same (one line with kill-emacs).  More lisp code in
emacsclient variant, but that is just because you put it all on one line
:)

Code size does not matter indeed.  Your approach just feels more of a
hack to me and unnecessary complex.  Again, this is just my IMHO.

I would like to hear what other (Carl in particular) think about this.
If the consensus is for your approach, I would be happy to implement it.

Regards,
  Dmitry


More information about the notmuch mailing list