MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / p2_cli_stdio_write_flushes

Function p2_cli_stdio_write_flushes

tests/all/cli_tests.rs:1416–1445  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1414 // character shows up here even as the guest is waiting on input via stdin.
1415 #[test]
1416 fn p2_cli_stdio_write_flushes() -> Result<()> {
1417 fn run(args: &[&str]) -> Result<()> {
1418 println!("running {args:?}");
1419 let mut child = get_wasmtime_command()?
1420 .args(args)
1421 .stdin(Stdio::piped())
1422 .stdout(Stdio::piped())
1423 .spawn()?;
1424 let mut stdout = child.stdout.take().unwrap();
1425 let mut buf = [0; 10];
1426 match stdout.read(&mut buf) {
1427 Ok(2) => assert_eq!(&buf[..2], b"> "),
1428 e => panic!("unexpected read result {e:?}"),
1429 }
1430 drop(stdout);
1431 drop(child.stdin.take().unwrap());
1432 let status = child.wait()?;
1433 assert!(status.success());
1434 Ok(())
1435 }
1436
1437 run(&["run", "-Spreview2=n", P2_CLI_STDIO_WRITE_FLUSHES])?;
1438 run(&["run", "-Spreview2=y", P2_CLI_STDIO_WRITE_FLUSHES])?;
1439 run(&[
1440 "run",
1441 "-Wcomponent-model",
1442 P2_CLI_STDIO_WRITE_FLUSHES_COMPONENT,
1443 ])?;
1444 Ok(())
1445 }
1446
1447 #[test]
1448 fn p2_cli_no_tcp() -> Result<()> {

Callers

nothing calls this directly

Calls 2

OkFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected