1 ///! This crate exists to build crates for wasm32-wasi in build.rs, and execute
2 ///! these wasm programs in harnesses defined under tests/.
3 
4 /// The wasi-tests binaries use these environment variables to determine their
5 /// expected behavior.
6 /// Used by all of the tests/ which execute the wasi-tests binaries.
7 pub fn wasi_tests_environment() -> &'static [(&'static str, &'static str)] {
8     #[cfg(windows)]
9     {
10         &[
11             ("ERRNO_MODE_WINDOWS", "1"),
12             // Windows does not support dangling links or symlinks in the filesystem.
13             ("NO_DANGLING_FILESYSTEM", "1"),
14             // Windows does not support renaming a directory to an empty directory -
15             // empty directory must be deleted.
16             ("NO_RENAME_DIR_TO_EMPTY_DIR", "1"),
17             // cap-std-sync does not support the sync family of fdflags
18             ("NO_FDFLAGS_SYNC_SUPPORT", "1"),
19         ]
20     }
21     #[cfg(all(unix, not(target_os = "macos")))]
22     {
23         &[
24             ("ERRNO_MODE_UNIX", "1"),
25             // cap-std-sync does not support the sync family of fdflags
26             ("NO_FDFLAGS_SYNC_SUPPORT", "1"),
27         ]
28     }
29     #[cfg(target_os = "macos")]
30     {
31         &[
32             ("ERRNO_MODE_MACOS", "1"),
33             // cap-std-sync does not support the sync family of fdflags
34             ("NO_FDFLAGS_SYNC_SUPPORT", "1"),
35         ]
36     }
37 }
38 
39 pub fn stdio_is_terminal() -> bool {
40     use is_terminal::is_terminal;
41     is_terminal(&std::io::stdin())
42         && is_terminal(&std::io::stdout())
43         && is_terminal(&std::io::stderr())
44 }
45