nextest-rs / nextest

A next-generation test runner for Rust.
https://nexte.st
Apache License 2.0
2.13k stars 92 forks source link

Manipulating the terminal causes tests to be stuck (linux) #945

Open sigmaSd opened 1 year ago

sigmaSd commented 1 year ago

code:

cargo add crossterm

#[test]
fn t() {
    // both of these freeze cargo next-test run
    // crossterm::terminal::enable_raw_mode().unwrap();
    // crossterm::cursor::position().unwrap();
}
sunshowers commented 1 year ago

Thanks. This is a good flag -- what's happened is that this causes the child to raise a SIGTTOU signal on itself, and the default behavior of that signal is to put the process in a stopped state (similar to ctrl-Z). Nextest doesn't currently know how to deal with tests in this kind of stopped state.

sunshowers commented 1 year ago

I wish there were a way to change the signal handler for SIGTTOU/SIGTTIN to terminate the process, but I don't believe there is.

Probably too intrusive for a test runner, to be honest. I think the out-of-process mechanics used by nextest (termination, timeouts) should generally be the extent of what we do.

The pty would definitely be interesting as well.

ClementTsang commented 8 months ago

Recently tried using the portable_pty crate (commit here) to test a TUI application; nextest seems to work with it.

sunshowers commented 8 months ago

Yes, if we allow using a pty for each test, then I was eyeing the portable_pty crate to make that happen.