Reputation: 1242
I am try to write regression tests using expect for an interactive bash script.
So far everything works Ok. I spawn the process with the correct arguments, and then send
/expect
.
I would like, during tests, to enable tracing in the bash script, using the set -x
command. However, when doing so, the bash trace output messes with expect.
I would like expect to ignore those lines when performing matching but still output them on either stdout or stderr.
Apperently, there is so way to treat stderr and stdout independently.
I have already tried a few thing using expect_before
and expect_background
, but none having given me good results.
Any thoughts ?
Thanks.
Upvotes: 0
Views: 207
Reputation: 5721
If the output (I mean non-trace output) from your bash
script if well-defined, you can simply ignore the trace output when using expect
command. For example, if your script shows:
+ echo 'Password:'
Password:
you can use regexp mode of expect
:
expect -re '^Password:'
That would ignore the trace output but match the password prompt. Granted, your match rules should be very tight to not match any undesirable output.
Upvotes: 0