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

Cannot enable raw mode on CI (test suite) #538

Closed
orhun opened this issue Feb 1, 2021 · 2 comments
Closed

Cannot enable raw mode on CI (test suite) #538

orhun opened this issue Feb 1, 2021 · 2 comments

Comments

@orhun
Copy link
Contributor

orhun commented Feb 1, 2021

Describe the bug
I'm using tui-rs & crossterm for my gpg-tui project and I have a test where I want to test if the TUI is functional by executing only the init functions. I'm not sure it's a good idea to attempt to test this case but I'm curious since it fails on GitHub actions but works on my setup. I've read from some of the issues here that it might be about tty and I very much like to know why/how this happens.

To Reproduce
Steps to reproduce the behavior:

  1. Run the following test suite on a CI with cargo test:
#[cfg(test)]
mod tests {
    use crossterm::event::EnableMouseCapture;
    use crossterm::terminal::{self, EnterAlternateScreen};
    use std::error::Error;
    use std::io;
    use tui::backend::TestBackend;
    use tui::Terminal;
    #[test]
    fn test_tui() -> Result<(), Box<dyn Error>> {
        let backend = TestBackend::new(10, 10);
        let mut terminal = Terminal::new(backend)?;
        terminal::enable_raw_mode()?;
        crossterm::execute!(io::stdout(), EnterAlternateScreen, EnableMouseCapture)?;
        terminal.hide_cursor()?;
        terminal.clear()?;
        Ok(())
    }
}

or without tui stuff (result is the same):

#[cfg(test)]
mod tests {
    use crossterm::event::EnableMouseCapture;
    use crossterm::terminal::{self, EnterAlternateScreen};
    use std::error::Error;
    use std::io;
    #[test]
    fn test_tui() -> Result<(), Box<dyn Error>> {
        terminal::enable_raw_mode()?;
        crossterm::execute!(io::stdout(), EnterAlternateScreen, EnableMouseCapture)?;
        Ok(())
    }
}
  1. See error:
 Error: IoError(Os { code: 6, kind: Other, message: "No such device or address" })
thread 'tests::test_tui' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/test/src/lib.rs:193:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test tests::test_tui ... FAILED

failures:

failures:
    tests::test_tui

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

Expected behavior
Passed tests.

OS
runs-on: ubuntu-latest

@TimonPost
Copy link
Member

A CI test suite is not able to use TTY device. Therefore it throws a 'No such device address error. And CI terminal is different from a desktop terminal.

@TimonPost
Copy link
Member

see: #580

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