Skip to content

Commit

Permalink
Fix the test_ttyname_ok test when /dev/stdin is inaccessable. (#821)
Browse files Browse the repository at this point in the history
/dev/stdin may be inaccessible in some sandboxed configurations, so just
gracefully return if opening it fails.
  • Loading branch information
sunfishcode committed Oct 12, 2023
1 parent d817bac commit 490b737
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/termios/ttyname.rs
Expand Up @@ -4,7 +4,11 @@ use std::fs::File;

#[test]
fn test_ttyname_ok() {
let file = File::open("/dev/stdin").unwrap();
let file = match File::open("/dev/stdin") {
Ok(file) => file,
Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return,
Err(err) => Err(err).unwrap(),
};
if isatty(&file) {
assert!(ttyname(&file, Vec::new())
.unwrap()
Expand Down

0 comments on commit 490b737

Please sign in to comment.