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

Function run_wasmtime_piped

tests/all/piped_tests.rs:7–39  ·  view source on GitHub ↗
(component_path: &str)

Source from the content-addressed store, hash-verified

5use wasmtime::Result;
6
7pub fn run_wasmtime_piped(component_path: &str) -> Result<()> {
8 let mut producer = get_wasmtime_command()?
9 .arg("run")
10 .arg("-Wcomponent-model")
11 .arg("--env")
12 .arg("PIPED_SIDE=PRODUCER")
13 .arg(component_path)
14 .stdout(Stdio::piped())
15 .spawn()?;
16
17 let mut consumer = get_wasmtime_command()?
18 .arg("run")
19 .arg("-Wcomponent-model")
20 .arg("--env")
21 .arg("PIPED_SIDE=CONSUMER")
22 .arg(component_path)
23 .stdin(producer.stdout.take().unwrap())
24 .spawn()?;
25
26 let producer = producer.wait()?;
27 if !producer.success() {
28 // make sure the consumer gets killed off
29 if consumer.try_wait().is_err() {
30 consumer.kill().expect("Failed to kill consumer");
31 }
32
33 panic!("Producer failed");
34 }
35
36 assert!(consumer.wait()?.success(), "Consumer failed");
37
38 Ok(())
39}
40
41mod test_programs {
42 use super::run_wasmtime_piped;

Callers 3

piped_simpleFunction · 0.85
piped_multipleFunction · 0.85
piped_pollingFunction · 0.85

Calls 11

get_wasmtime_commandFunction · 0.85
OkFunction · 0.85
spawnMethod · 0.45
stdoutMethod · 0.45
argMethod · 0.45
stdinMethod · 0.45
unwrapMethod · 0.45
takeMethod · 0.45
waitMethod · 0.45
successMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected