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

Testing interactive programs #101

Open
dnaka91 opened this issue Jun 9, 2022 · 4 comments
Open

Testing interactive programs #101

dnaka91 opened this issue Jun 9, 2022 · 4 comments
Labels
enhancement Improve the expected

Comments

@dnaka91
Copy link

dnaka91 commented Jun 9, 2022

Thanks for this awesome library, it looks really awesome.

I was wondering if there is some support or setting that'd allow testing a binary that expects inputs from the user on the terminal.

Currently, I tried setting that up by using the *.toml format and providing a *.stdin file.

That unfortunately doesn't seem to work, as I get the error Failed to initialize input reader from the library I use (inquire). So it seems it needs some kind of proper TTY/PTY to function properly.

All the other features look really great, as my project is a code generator for new projects, and I want to verify that the generation works, where the *.out features is extremely convenient for verification.

@epage
Copy link
Contributor

epage commented Jun 9, 2022

Sounds like there are two requests here, TTY support so it can work with inquire and pexpect support.

Could you split these out into separate issues?

@dnaka91
Copy link
Author

dnaka91 commented Jun 10, 2022

I split off the request about pexpect-ish support into #102 now 🙇‍♂️

@dnaka91
Copy link
Author

dnaka91 commented Jun 10, 2022

To give some more details about the inquire crate: I use it with the crossterm crate as backend, and it uses its enable_raw_mode when prompting the user. If that one fails (as it does without a TTY), it'll not be able to run the prompt.

So some sort of TTY or PTY seems to be definitely required for this, and likely for other interactive CLI apps too, as it needs some way to access advanced terminal features, rather than just stdin/stdout.

@epage
Copy link
Contributor

epage commented Jun 10, 2022

https://docs.rs/portable-pty/0.7.0/portable_pty/ might be useful for this

@epage epage added the enhancement Improve the expected label Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants