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