Skip to content

Commit f416b6b

Browse files
committed
Fix the test_ttyname_ok test when /dev/stdin is inaccessable. (#821)
/dev/stdin may be inaccessible in some sandboxed configurations, so just gracefully return if opening it fails.
1 parent aee5b09 commit f416b6b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/termios/ttyname.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use std::fs::File;
44

55
#[test]
66
fn test_ttyname_ok() {
7-
let file = File::open("/dev/stdin").unwrap();
7+
let file = match File::open("/dev/stdin") {
8+
Ok(file) => file,
9+
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return,
10+
Err(err) => Err(err).unwrap(),
11+
};
812
if isatty(&file) {
913
assert!(ttyname(&file, Vec::new())
1014
.unwrap()

0 commit comments

Comments
 (0)