only run termios test if stdin is a tty

This commit is contained in:
Lion Kortlepel
2022-05-26 16:14:05 +02:00
parent 70e53c2a70
commit 46b92b4992
+13 -11
View File
@@ -24,18 +24,20 @@ void resetTermios(void) {
} }
TEST_CASE("init and reset termios") { TEST_CASE("init and reset termios") {
struct termios original; if (isatty(STDIN_FILENO)) {
tcgetattr(0, &original); struct termios original;
SUBCASE("no echo") { tcgetattr(0, &original);
initTermios(false); SUBCASE("no echo") {
initTermios(false);
}
SUBCASE("yes echo") {
initTermios(true);
}
resetTermios();
struct termios current;
tcgetattr(0, &current);
CHECK(std::memcmp(&original, &current, sizeof(struct termios)) == 0);
} }
SUBCASE("yes echo") {
initTermios(true);
}
resetTermios();
struct termios current;
tcgetattr(0, &current);
CHECK(std::memcmp(&original, &current, sizeof(struct termios)) == 0);
} }
char getch_(int echo) { char getch_(int echo) {