• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![cfg(not(target_os = "wasi"))]
2 
3 use std::env;
4 use std::process::Command;
5 
6 /// Use `dup2` to replace the stdin and stdout file descriptors.
7 #[test]
dup2_to_replace_stdio()8 fn dup2_to_replace_stdio() {
9     // This test modifies the stdio file descriptors, so we run it in a
10     // separate process so that it doesn't interfere with the test harness.
11     assert!(Command::new(env::var("CARGO").unwrap())
12         .arg("run")
13         .arg("--example")
14         .arg("dup2_to_replace_stdio")
15         .status()
16         .unwrap()
17         .success());
18 }
19