From 1c9f3682f5d95ccb5bd7d9f3e49dd49df5e9ee4e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 21 Oct 2022 14:16:12 +0200 Subject: [PATCH] test is_terminal --- src/tools/miri/tests/pass/shims/fs.rs | 5 ++++- src/tools/miri/tests/pass/shims/io.rs | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/tools/miri/tests/pass/shims/io.rs diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs index 1758e486ac3..65cf6fe66ba 100644 --- a/src/tools/miri/tests/pass/shims/fs.rs +++ b/src/tools/miri/tests/pass/shims/fs.rs @@ -3,6 +3,7 @@ #![feature(io_error_more)] #![feature(io_error_uncategorized)] +#![feature(is_terminal)] use std::collections::HashMap; use std::ffi::OsString; @@ -10,7 +11,7 @@ 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() { @@ -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(); } diff --git a/src/tools/miri/tests/pass/shims/io.rs b/src/tools/miri/tests/pass/shims/io.rs new file mode 100644 index 00000000000..4d43549a930 --- /dev/null +++ b/src/tools/miri/tests/pass/shims/io.rs @@ -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(); +}