Skip to content

Commit a822e52

Browse files
committed
Don't assume that the tests are connected to a tty.
1 parent bd291ac commit a822e52

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/termios/ttyname.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
use rustix::io;
2-
use rustix::termios::ttyname;
2+
use rustix::termios::{isatty, ttyname};
33
use std::fs::File;
44

55
#[test]
66
fn test_ttyname_ok() {
77
let file = File::open("/dev/stdin").unwrap();
8-
assert!(ttyname(&file, Vec::new())
9-
.unwrap()
10-
.into_string()
11-
.unwrap()
12-
.starts_with("/dev/"));
8+
if isatty(&file) {
9+
assert!(ttyname(&file, Vec::new())
10+
.unwrap()
11+
.into_string()
12+
.unwrap()
13+
.starts_with("/dev/"));
14+
}
1315
}
1416

1517
#[test]

0 commit comments

Comments
 (0)