()
| 2960 | #[test] |
| 2961 | #[cfg_attr(not(feature = "component-model-async"), ignore)] |
| 2962 | fn p3_cli_stdout_flush() -> Result<()> { |
| 2963 | let mut child = get_wasmtime_command()? |
| 2964 | .arg("-Sp3") |
| 2965 | .arg("-Wcomponent-model-async") |
| 2966 | .arg(P3_CLI_STDOUT_FLUSH_COMPONENT) |
| 2967 | .stdin(Stdio::piped()) |
| 2968 | .stdout(Stdio::piped()) |
| 2969 | .stderr(Stdio::piped()) |
| 2970 | .spawn()?; |
| 2971 | |
| 2972 | let mut stdin = child.stdin.take().unwrap(); |
| 2973 | let mut stdout = child.stdout.take().unwrap(); |
| 2974 | |
| 2975 | let (tx, rx) = std::sync::mpsc::channel(); |
| 2976 | let reader = thread::spawn(move || { |
| 2977 | let mut buf = [0u8; 5]; |
| 2978 | let res = stdout.read_exact(&mut buf).map(|()| buf); |
| 2979 | let _ = tx.send(res); |
| 2980 | }); |
| 2981 | |
| 2982 | let buf = match rx.recv_timeout(std::time::Duration::from_secs(100)) { |
| 2983 | Ok(Ok(buf)) => buf, |
| 2984 | Ok(Err(e)) => { |
| 2985 | let _ = child.kill(); |
| 2986 | let _ = child.wait(); |
| 2987 | return Err(e.into()); |
| 2988 | } |
| 2989 | Err(_) => { |
| 2990 | let _ = child.kill(); |
| 2991 | let _ = child.wait(); |
| 2992 | let _ = reader.join(); |
| 2993 | panic!("guest stdout was not flushed"); |
| 2994 | } |
| 2995 | }; |
| 2996 | assert_eq!(&buf, b"READY"); |
| 2997 | |
| 2998 | stdin.write_all(b"x")?; |
| 2999 | drop(stdin); |
| 3000 | |
| 3001 | let output = child.wait_with_output()?; |
| 3002 | reader.join().unwrap(); |
| 3003 | assert!(output.status.success()); |
| 3004 | |
| 3005 | Ok(()) |
| 3006 | } |
| 3007 | |
| 3008 | #[tokio::test] |
| 3009 | async fn p3_cli_serve_post_return() -> Result<()> { |
nothing calls this directly
no test coverage detected