Skip to content

Commit

Permalink
test is_terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 21, 2022
1 parent 2041f53 commit fb9a681
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/pass/shims/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

#![feature(io_error_more)]
#![feature(io_error_uncategorized)]
#![feature(is_terminal)]

use std::collections::HashMap;
use std::ffi::OsString;
use std::fs::{
canonicalize, create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename,
File, OpenOptions,
};
use std::io::{Error, ErrorKind, Read, Result, Seek, SeekFrom, Write};
use std::io::{Error, ErrorKind, IsTerminal, Read, Result, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};

fn main() {
Expand Down Expand Up @@ -91,6 +92,8 @@ fn test_file() {
file.read_to_end(&mut contents).unwrap();
assert_eq!(bytes, contents.as_slice());

assert!(!file.is_terminal());

// Removing file should succeed.
remove_file(&path).unwrap();
}
Expand Down
9 changes: 9 additions & 0 deletions tests/pass/shims/io.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![feature(is_terminal)]

use std::io::IsTerminal;

fn main() {
// We can't really assume that this is truly a terminal, and anyway on Windows Miri will always
// return `false` here, but we can check that the call succeeds.
std::io::stdout().is_terminal();
}

0 comments on commit fb9a681

Please sign in to comment.