()
| 513 | #[cfg(unix)] |
| 514 | #[test] |
| 515 | fn run_cwasm_from_stdin() -> Result<()> { |
| 516 | use std::process::Stdio; |
| 517 | |
| 518 | let td = TempDir::new()?; |
| 519 | let cwasm = td.path().join("foo.cwasm"); |
| 520 | let stdout = run_wasmtime(&[ |
| 521 | "compile", |
| 522 | "tests/all/cli_tests/simple.wat", |
| 523 | "-o", |
| 524 | cwasm.to_str().unwrap(), |
| 525 | ])?; |
| 526 | assert_eq!(stdout, ""); |
| 527 | |
| 528 | // If stdin is literally the file itself then that should work |
| 529 | let args: &[&str] = &["run", "--allow-precompiled", "-"]; |
| 530 | let output = get_wasmtime_command()? |
| 531 | .args(args) |
| 532 | .stdin(File::open(&cwasm)?) |
| 533 | .output()?; |
| 534 | assert!(output.status.success(), "a file as stdin should work"); |
| 535 | |
| 536 | // If stdin is a pipe, that should also work |
| 537 | let input = std::fs::read(&cwasm)?; |
| 538 | let mut child = get_wasmtime_command()? |
| 539 | .args(args) |
| 540 | .stdin(Stdio::piped()) |
| 541 | .stdout(Stdio::piped()) |
| 542 | .stderr(Stdio::piped()) |
| 543 | .spawn()?; |
| 544 | let mut stdin = child.stdin.take().unwrap(); |
| 545 | let t = std::thread::spawn(move || { |
| 546 | let _ = stdin.write_all(&input); |
| 547 | }); |
| 548 | let output = child.wait_with_output()?; |
| 549 | assert!(output.status.success()); |
| 550 | t.join().unwrap(); |
| 551 | Ok(()) |
| 552 | } |
| 553 | |
| 554 | #[cfg(feature = "wasi-threads")] |
| 555 | #[test] |
nothing calls this directly
no test coverage detected