poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recently broken tab completion in repl


From: Jose E. Marchesi
Subject: Re: Recently broken tab completion in repl
Date: Sun, 12 Apr 2020 11:28:04 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi John.

         Hm, it actually does what I intended.
         
         As far as I can tell the problem in
         c576c04c32c10f1f550229b0c487ded1f4948e53 impacted the echo of the typed
         entry on the prompt, but not the autocompleted command that poke
         received, i.e.
         
         (poke) .se\t obase 16
         
         What you see: (poke) .se  obase 16
         What the rl edit line has and poke receives: .set obase 16
         
         So poke didn't fail when you sent ".se\t obase 16", and therefore
         replied with the prompt which is what the {} for PATTERN in the
         poke_test_cmd invocation means...
    
    
    I'm not sure that I follow.  But anyway what we really need is a test
    that will ensure (for example) that when I type:
    
    (poke) .e\t\t  [no newline]
    
    Then I get the response:
    
    .editor  .exit
    
    But I don't know  how to do that (or much else) using deja-gnu.
    
Oh I see.

Ok, I added a new utility function poke_send that allows writing tests
that are not about executing poke commands.

So now the tab-completion tests look like:

set test "tab-completion-1"
poke_start
poke_send ".se\t" ".set"
poke_exit

set test "tab-completion-2"
poke_start
poke_send ".e\t\t" "\r\n.editor  .exit *\r\n$poke_prompt .e"
poke_exit

poke_test_cmd stays for convenience.
Excerpt from HACKING:

Writing REPL tests
~~~~~~~~~~~~~~~~~~

Th the ``poke.repl`` testsuite is intended to test features in the
interactive usage of poke.  Therefore, it is not dg-based.  Instead,
it uses the services provided by ``testsuite/lib/poke.exp``.  In a
nutshell, these services are:

poke_start
  Run a new poke process and wait at the prompt.
poke_exit
  Exit poke.
poke_test_cmd CMD PATTERN
  Send CMD to poke, and expect the result PATTERN.  CMD is sent as
  virtual keystrokes.  Therefore, sending \t or \n has the same effect
  on the REPL than typing TAB or RET in the keyboard, respectively.
  PATTERN shouldn't include the prompt.
poke_send INPUT PATTERN
  Send INPUT to poke, and expect PATTERN as output.
  
Adding a new test to ``poke.repl`` involves editing
``poke.repl/repl.exp`` and adding some content there.  The following
subsections detail how.

Command REPL tests
..................

Some REPL tests need to check whether poke replies properly to some
sent command.  The ``poke_test_cmd`` procedure defined in
``testsuite/lib/poke.exp`` provides a convenient interface for this.

For example::
  
  set test "slashes are preserved"
  poke_start
  poke_test_cmd {4 / 2} {2}
  poke_exit

The snippet above implements a test named "slashes are preserved" that
runs poke and sends the command ``4 / 2`` with expected result ``2``.

The dialogue when the test above is executed is::

  (poke) 4 / 2
  2
  (poke) 

General REPL tests
..................

Other REPL tests are not about executing commands.  Suppose for
example we want to test whether tab-completion works.  We would write
something like::
  
  set test "tab-completion-2"
  poke_start
  poke_send ".e\t\t" "\r\n.editor  .exit *\r\n$poke_prompt .e"
  poke_exit

The test above uses the ``poke_send`` procedure, defined in
``testsuite/lib/poke.exp``.  This procedure gets two arguments: the
input that is sent to poke, and the expected output.  Note how usign
``poke_send`` doesn't require poke to execute any command.

Using ``poke_send`` is more laborious than using ``poke_test_cmd``: it
is necessary to explicitly include the prompt in the expected output
whenever needed.

Note also how newlines are perceived by expect as the sequence
``\r\n``.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]