-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add option to use a pty for tests (Inappropriate ioctl for device error during TUI tests) #1357
Comments
Thanks for the issue, and also for maintaining ratatui which I love! This occurs because nextest doesn't allocate a pty for each test. It's something I've been wanting to do but never have had the time to. We aren't going to change the default, but this is something that can be managed in configuration -- for some or all tests, as desired. I don't have the time to work on it within the next few weeks, but I think you're kind of an expert in the area being a ratatui maintainer! If you'd like to implement this I'd love it -- we just need to add a |
Absolutely, I would love to take a stab at this issue. Not sure when but I'm thinking I can get to it pretty soon. Thanks for the explanation and kind words! 🧀 |
Hello again! Sorry it took me forever to get to this. I have a couple of points that I might need your guidance:
First, I thought of using
I'm not fully familiar with the codebase but I'm guessing we would like to add a config option. But maybe I misunderstood that, can you clarify what you mean by per-test overrides? |
Thanks! I think the way to address that would be to write an abstraction over the different ways to run various commands, behind an enum or trait object. However, I noticed while looking at portable-pty that it doesn't seem to have async support. So we may need to wrap portable-pty to make it work in the async world. To do this, we have to think about a few things:
@wez -- hey! Wondering if you have thoughts on making portable-pty work with async. Is that something you'd be willing to accept upstream? |
hey @sunshowers! portable-pty doesn't currently implement async directly because Windows conpty is documented as only supporting synchronous I/O: https://learn.microsoft.com/en-us/windows/console/createpseudoconsole
(and the same for its output). Whether that happens to work with IO completion ports or other async techniques on Windows, I don't know. From a system's perspective, in portable-pty, those streams are always pipes which are fundamentally compatible with async IO, but I'm not sure what sorts of other magic maybe involved that this restriction is documented. Maybe @DHowett-MSFT can weigh in on this? We do have an example of async use at a higher level via the smol crate and its Unblock helper: https://github.com/wez/wezterm/blob/main/pty/examples/whoami_async.rs I'm certainly open to PRs that make this more integrated, but I do want to note that it is desirable (although not a fully hard requirement if a good case is made for it) that the implementation doesn't make tokio a requirement for the crate. The reason being that wezterm's async runtime is I think the signals side of this might be a bit easier to wrangle, but I do want to note that synchronizing output/error and signal delivery is a potentially tricky problem, because the output/error pipes may still have buffered data at the time a signal is detected. |
Thanks @wez! The whoami_async approach makes sense to me.
Hmm the Tokio code to handle things like SIGCHLD is pretty hairy, requiring global tracking of all processes since SIGCHLD can be coalesced. See https://github.com/tokio-rs/tokio/blob/6fcd9c02176bf3cd570bc7de88edaa3b95ea480a/tokio/src/process/unix/reap.rs |
Oh yeah, SIGCHLD is objectively horrible. When it comes to ptys I think wrapping it up in something like spawn_blocking + the underlying synchronous |
It'll be typically 10s of ptys, not thousands thankfully. |
Hello 👋🏼
We are experiencing some
nextest
related test failures here: ratatui/ratatui#981In a nutshell, initializing a terminal with ratatui with termion backend during tests throws the following error for
cargo nextest run
:Whereas
cargo test
works fine.Here is a minimal reproducibility example:
Then add the following test:
cargo nextest run
:Details
cargo test
:Details
The text was updated successfully, but these errors were encountered: