Commit Graph

17 Commits

Author SHA1 Message Date
ridiculousfish
cfbebb7201 Better support for helper functions in pexpect
When a pexpect test fails, it reports the "failing line." Prior to this
commit, it did so by walking up the Python call stack, looking for
the first frame which is not in the pexpect_helper module, and so presumably
in the test itself. However sometimes the test wants to define a helper
function; then if the test fails the helper function is reported as the
failing line, not the callsite of the helper.

Fix this by skipping functions which have the `callsite_skip` attribute set.

Nothing to relnote here.
2022-04-10 12:59:04 -07:00
ridiculousfish
e08b71592e pexpect_helper to unconditionally output to the tty
With the new test runner, pexpect_helper no longer sees a tty so wasn't
outputting the buffer. Just always do it.
2021-10-29 20:45:42 -07:00
ridiculousfish
f373e6e923 Reformat pexpect_helper.py with black 2021-10-29 20:42:59 -07:00
Fabian Homborg
23e6698dc8 cmake: Force color in the tests
For littlecheck/pexpect this just unconditionally enables color.

I have no idea what happens if you run cmake outside of a terminal
, but the worst that can happen is that *errors* have color
escapes in them.

If someone figures out how to get cmake to tell us if it's running in
a terminal, we can add a check.
2021-08-30 17:16:19 +02:00
Johannes Altmanninger
516a70d9cb Misc cleanups
Some as suggested by lgtm.com
2021-03-21 19:41:36 +01:00
Fabian Homborg
81af5b7ff3 pexpect: Allow specifying that a test should fail
I have no idea how to see that flow control has worked otherwise
2021-02-15 17:30:50 +01:00
Fabian Homborg
ccc5e7cb28 pexpect: Pass on keyword arguments to spawn()
This is useful for all the additional pexpect features.
2021-02-12 18:21:07 +01:00
Fabian Homborg
2e55e34544 Reformat 2020-11-22 14:39:48 +01:00
ridiculousfish
63cf3e972f Correct parameter order of pexpect.expect_prompt
Ensure that the increment= param is set via keyword, not via positional arg.
This mistake was masking a bug where the "^a b c" match was not being tested,
because it was being set as the value for increment!
2020-10-06 16:03:06 -07:00
ridiculousfish
9e1800cb96 Rework increment param in pexpect.expect_prompt
This switches the 'increment' param from "after" to "before." Instead
of expect_prompt saying if the next prompt will be incremented, each
call site says if it should have been incremented sinec the last prompt.
2020-10-06 14:22:35 -07:00
Fabian Homborg
04562300e8 Pexpect: Return the match object instead of the result
The result is just the *index* of the pattern that matched. But since
we never pass a *list* it's just always 0.

spawn.match is the MatchObject that produced the match, so it can be
used to post-process the matched output, e.g.

```python
m = expect_re('\d+')
m.group() # is now the matched number
```
2020-09-04 17:53:17 +02:00
ridiculousfish
47480b2dbd Remove redraw coalescing logic
Prior to this change, if we saw more than one repaint readline command in
a row, we would try to ignore the second one. However this was never the
right thing to do since sometimes we really do need to repaint twice in a
row (e.g. the user hits Ctrl+L twice). Previously we were saved by the
buginess of this mechanism but with the repainting refactoring we see
missing redraws.

Remove the coalescing logic and add a test. Fixes #7280.
2020-08-24 13:22:35 -07:00
Fabian Homborg
149a0b98af Another formatting run
I really kinda hate how insistent clang-format is to have line
breaks *IFF THE LINE IS TOO LONG*.

Like... lemme just add a break if it looks better, will you?

But it is the style at this time, so we shall tie an onion to our
belt.
2020-06-24 20:43:56 +02:00
Fabian Homborg
cfa2927610 pexpect: Show last 10 lines on failure
This was sometimes slightly annoying in porting.

5 is enough most of the time, 10 should be enough basically always,
without being too annoying if you don't need it.
2020-06-13 19:53:21 +02:00
Fabian Homborg
5478d979a0 pexpect: Consume color sequences in expect_prompt
We typically use TERM=dumb, but in some cases we need actual cursor
and color stuff.
2020-06-13 19:18:12 +02:00
ridiculousfish
4ae4314e63 Improve pexpect output
Make it easier to use pexpect and to understand its error messages.
Switch to a style in tests using bound methods, which makes them
less noisy to write.
2020-06-07 14:53:17 -07:00
ridiculousfish
3b7feb38e9 Add pexpect-based interactive testing framework
This adds a new interactive test framework based on Python's pexpect. This
is intended to supplant the TCL expect-based tests.

New tests go in `tests/pexpects/`. As a proof-of-concept, the
pipeline.expect test and the (gnarly) bind.expect test are ported to the
new framework.
2020-06-07 14:46:21 -07:00