Executes `image` through completion in `vm`, and converts the result into an exit code.
(vm: &mut Vm, image: &Image)
| 487 | |
| 488 | /// Executes `image` through completion in `vm`, and converts the result into an exit code. |
| 489 | async 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 |
no test coverage detected