From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24237 invoked by alias); 21 Dec 2011 16:48:30 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30040 Received: (qmail 5659 invoked from network); 21 Dec 2011 16:48:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <111221084801.ZM13070@torch.brasslantern.com> Date: Wed, 21 Dec 2011 08:48:01 -0800 In-reply-to: Comments: In reply to Felix Rosencrantz "Adding tests for zle? The missing X series tests" (Dec 20, 8:20am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Adding tests for zle? The missing X series tests MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 20, 8:20am, Felix Rosencrantz wrote: } } There are no zle tests, though the letter X was reserved for } zle tests. I was wondering if anyone had thought about how this might } be done. I have thought a bit about this in the past and I think there may be a sort of brute-force way to do it. It wouldn't work for everything, but it should work for most simple ZLE edits and for incremental search in particular. First you'd need to set up a zpty session like the completion tests do. Make sure to give it adequate dimensions so ZLE scrolling does not kick in (unless that's what you're testing, I guess). Next you set PS1 to a recognizable string and clear RPS1 etc. For some tests you'd might want a recognizable PS2 as well, but for incremental search it wouldn't be necessary. Finally you arrange that clear-screen is bound to a well-known keystroke (the defaut of ctrl-L is probably fine). Now you're ready to test. Start sending keystrokes to the zpty and read back (and probably discard) the zpty output as you do so. At the point where you want to check the result, send clear-screen, which causes the whole screen to be redrawn (even during incremental search) including the PS1 prompt. This repaint should result in pretty much a linear dump of the editor buffers with few or no cursor movements after the initial screen clear. Consequently your next zpty read after the clear-screen can scan for the PS1 string you set previously, in order to skip over the terminal control output, and then slurp up everything else that was printed and compare to what you expected to find. (A quick check using the script command to capture output indicates that there is a clear-to-end-of-line emitted at the end of each line of the output, but that should be relatively easy to ignore when parsing.) This won't uncover terminal-handling bugs like unexpected line wraps at the last line/column, but it should be able to verify e.g. the search is finding the right thing at each incremental step.