Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3F319429E32 for ; Mon, 27 Jun 2011 20:49:49 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H9sKoM6wuG+a for ; Mon, 27 Jun 2011 20:49:48 -0700 (PDT) Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU [18.7.68.37]) by olra.theworths.org (Postfix) with ESMTP id B73C9429E25 for ; Mon, 27 Jun 2011 20:49:48 -0700 (PDT) X-AuditID: 12074425-b7b82ae000000a2a-77-4e094f3739a9 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 71.1C.02602.73F490E4; Mon, 27 Jun 2011 23:49:11 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id p5S3nlQ0024916; Mon, 27 Jun 2011 23:49:48 -0400 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p5S3nk9C004457 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 27 Jun 2011 23:49:47 -0400 (EDT) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72) (envelope-from ) id 1QbPIv-0001u9-Ra; Mon, 27 Jun 2011 23:49:37 -0400 Date: Mon, 27 Jun 2011 23:49:37 -0400 From: Austin Clements To: Dmitry Kurochkin Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests Message-ID: <20110628034937.GB4120@mit.edu> References: <1309132379-24089-1-git-send-email-dmitry.kurochkin@gmail.com> <1309146846-30991-1-git-send-email-dmitry.kurochkin@gmail.com> <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com> <87hb7byqge.fsf@gmail.com> <87d3hyzs1c.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d3hyzs1c.fsf@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnleLIzCtJLcpLzFFi42IRYrdT0TX35/Qz6NplZnF1az+7xfWbM5kd mDx2zrrL7vFs1S3mAKYoLpuU1JzMstQifbsEroyXmztYCs4IVWy90sDewNjC18XIySEhYCLx ae1qNghbTOLCvfVANheHkMA+RolVM5dAORsYJV7vmsYO4Zxkkjj87gVUZgmjxO2et4xdjBwc LAKqEtfWB4CMYhPQkNi2fzkjiC0iYChx6+IrZhCbWUBa4tvvZiaQcmEBR4nrp1lAwrwC2hLX FrZCzd/LJHHz7DJmiISgxMmZT1ggerUkbvx7CdYLMmf5Pw6QMKeAusTFrT/APhAVUJG4tr+d bQKj0Cwk3bOQdM9C6F7AyLyKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10IvN7NELzWldBMjOKxd VHcwTjikdIhRgINRiYeXaSWHnxBrYllxZe4hRkkOJiVR3n/enH5CfEn5KZUZicUZ8UWlOanF hxglOJiVRHinGgHleFMSK6tSi/JhUtIcLErivCHe/32FBNITS1KzU1MLUotgsjIcHEoSvLF+ QI2CRanpqRVpmTklCGkmDk6Q4TxAw4NBaniLCxJzizPTIfKnGHU57j1aeZhRiCUvPy9VSpz3 OkiRAEhRRmke3BxYOnrFKA70ljDveZAqHmAqg5v0CmgJE9ASHVMOkCUliQgpqQZGp+u//82+ tlFPd5/Dk5Le3vh1iV1zyjeGcnouD2tN/xf76+yhQgVB/awvIpHTikx9Fae2cIpcN2h7Oum8 yW6PLzIHnvFfs1DMC7n358OKh+XaufPDb88qetkwL0jJunNpe0X39oPO+UF3zi3ImBUeVMR4 uzvtxekzPAv2N7YclfxVpVxx9yCDEktxRqKhFnNRcSIAL0LWLiIDAAA= Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jun 2011 03:49:49 -0000 Quoth Dmitry Kurochkin on Jun 28 at 5:03 am: > > > The only way I know to > > > reliably kill a child process is to open a pipe to it and have it exit > > > on its own when it reads EOF. Unfortunately, I couldn't find a way to > > > do this with an emacs daemon (it appears daemon mode aggressively > > > cleans up things like pipes), but here's a different approach: > > > > > > coproc emacs --batch --eval "(while t (eval (read)))" > > > EMACSFD=${COPROC[1]} > > > trap "echo '(kill-emacs)' >&$EMACSFD" EXIT > > > > > > echo '(message "Hi")' >&$EMACSFD > > > # ... > > > > > > This is, basically, a poor man's emacs server, but the coprocess pipe > > > binds it tightly to the shell. If the shell exits for *any* reason, > > > the pipe will be closed by the kernel, emacs will read an EOF, and > > > exit. > > > > I like this idea. > > > > > The trap is there just to cleanly shut down in case of a normal > > > exit [1]. > > > > For normal exit we should just put this into test_done. Otherwise it is > > not a normal exit and we do not care about Emacs error message. No? > > > > > This also has the advantage that read-from-minibuffer still > > > works: > > > > > > echo '(message (read-from-minibuffer ""))' >&$EMACSFD > > > echo 'Test' >&$EMACSFD > > > > > > Thoughts? > > > > > > > I like it and I will implement it. Thanks for the idea. > > > > While implementing the idea, I stumbled upon a problem: we need to know > when Emacs finished what we echoed or failed with an error. At the > moment tests fail because they check for OUTPUT before Emacs creates it. > > We can tell Emacs to print some special marker and wait for it. But > there may be exceptions and errors which may make it difficult. I did > not found a good solution yet. Would love to hear your thoughts :) Oof, yes, of course. How about making the one-line poor man's emacs server slightly less poor? Use a FIFO to communicate completion. Something like, 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