Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible testing with pexpect when external printer used #703

Open
godzie44 opened this issue Jun 12, 2023 · 2 comments
Open

Impossible testing with pexpect when external printer used #703

godzie44 opened this issue Jun 12, 2023 · 2 comments

Comments

@godzie44
Copy link

I'm using rustyline and python pexpect for integration testing. This worked fine, until i'm try to use an external_printer. With external_printer pextect.send do nothing.

Steps to reproduce

This can be reproduced on external_print example:

>>> import pexpect
>>> proc = pexpect.spawn('./target/debug/examples/external_print')
>>> proc.sendline('123')
>>> print(proc.readline())
b'\x1b[?2004h\r\x1b[K> \r\x1b[2C\r\x1b[KExternal message #0\r\n'
>>> print(proc.readline())
b'\r\x1b[K> \r\x1b[2C\r\x1b[KExternal message #1\r\n'
>>> print(proc.readline())

and so on, expected output "Line: 123" never reads.

Workaround

In my app i use cfg conditional checks for determine test environment or not, then in test env i replace external_printer.print to println!, but would be nice to have a better workaround...

@gwenn
Copy link
Collaborator

gwenn commented Jun 12, 2023

#690 reveals that rustyline doesn't behave correctly with expect / pexpect.
So maybe we should introduce a feature X (for testing) that deactivates input buffering ?
And maybe when this feature X is activated, external_printer are disabled ?
(I am not sure that we can actually activate a feature only for testing)

@godzie44
Copy link
Author

Yep i think better if feature for testing will be on rustyline side.
But there is still a problem, that output observable by user and output observable by integration tests may be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants