Use Expect.jl for interactive tests? #609
Replies: 1 comment
-
Update, after a discussion with @fingolfin : First, the input lines The really problematic part in the above input code is the julia> using Expect
julia> proc = ExpectProc(`path-to-your-gaproot/bin/gap.sh -q -A`, 16);
julia> println(proc, "LoadPackage(\"browse\");");
julia> println(proc, "?Size"); # open the Browse table
julia> print(proc, "ddd"); # navigate down three times
julia> print(proc, "\r"); # enter <Return>, this opens the pager with the help entry
julia> print(proc, "qq"); # quit the pager, quit the Browse table
julia> println(proc, "0+0;"); # make sure that there is a newline in the end
julia> bytesavailable(proc) # the value may depend on color settings etc.
6186
julia> output = [];
julia> while bytesavailable(proc) > 0 push!(output, readline(proc)) end
julia> length(output)
26
julia> close(proc) # kill the GAP process
|
Beta Was this translation helpful? Give feedback.
-
@fingolfin had listed
Expect.jl
as a tool for interactive tests. Examples where such tests are interesting are the GAP help system, functions that use GAP's Browse package, or Julia's terminal menus.Here are my first experiments.
First we start a GAP session.
We better start GAP without prompt (and without banner), and also without packages.
This looks reasonable.
Now let us look at the GAP help. The Browse package was not loaded, thus we get just a pager.
With the Browse package, the expected behaviour of GAP is different, and different input is needed.
Here the idea is that the menu of choices opens in a Browse table, one can move the focus down to the entry in question, and then choose it by entering
<Return>
(the character\r
).Initially this seemed to work, but after some experiments the whole setup became unstable, and
bytesavailable(proc)
returned0
from that point on.Even after closing all GAP processses with
close(proc)
and leaving all Julia sessions, still two GAP processes were alive on my computer --I do not understand what is going on.Here is some input that should work, but it doesn't work anymore.
Beta Was this translation helpful? Give feedback.
All reactions