MCPcopy Index your code
hub / github.com/endbasic/endbasic / run_image

Function run_image

core/tests/testutils/mod.rs:489–503  ·  view source on GitHub ↗

Executes `image` through completion in `vm`, and converts the result into an exit code.

(vm: &mut Vm, image: &Image)

Source from the content-addressed store, hash-verified

487
488/// Executes `image` through completion in `vm`, and converts the result into an exit code.
489async fn run_image(vm: &mut Vm, image: &Image) -> Result<i32, String> {
490 loop {
491 match vm.exec(image) {
492 StopReason::End(code) => return Ok(code.to_i32()),
493 StopReason::Eof => return Ok(0),
494 StopReason::UpcallAsync(handle) => {
495 if let Err(e) = handle.invoke().await {
496 return Err(e.to_string());
497 }
498 }
499 StopReason::Exception(pos, e) => return Err(format!("{}: {}", pos, e)),
500 StopReason::Yield => (),
501 }
502 }
503}
504
505/// Given a `golden` test definition, executes its source part and writes the corresponding
506/// `generated` file. The test is expected to pass when both match, but the caller is responsible

Callers 1

regenerateFunction · 0.85

Calls 3

to_i32Method · 0.80
invokeMethod · 0.80
execMethod · 0.45

Tested by

no test coverage detected