Executes the `path` program in a fresh machine.
(
path: P,
console_factory: Box<dyn ConsoleFactory>,
signals_chan: (Sender<Signal>, Receiver<Signal>),
gpio_pins_spec: Option<&str>,
)
| 95 | |
| 96 | /// Executes the `path` program in a fresh machine. |
| 97 | pub async fn run_script<P: AsRef<Path>>( |
| 98 | path: P, |
| 99 | console_factory: Box<dyn ConsoleFactory>, |
| 100 | signals_chan: (Sender<Signal>, Receiver<Signal>), |
| 101 | gpio_pins_spec: Option<&str>, |
| 102 | ) -> Result<i32> { |
| 103 | let builder = new_machine_builder(console_factory, signals_chan, gpio_pins_spec)?; |
| 104 | let mut machine = builder.build(); |
| 105 | let mut input = File::open(path)?; |
| 106 | |
| 107 | machine.compile(&mut input)?; |
| 108 | match machine.exec().await { |
| 109 | Ok(Some(code)) => Ok(code), |
| 110 | Ok(None) => Ok(0), |
| 111 | Err(StdError::Break) => Ok(INTERRUPTED_EXIT_CODE), |
| 112 | Err(e) => Err(e.into()), |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /// Executes the `path` program in a fresh machine allowing any interactive-only calls. |
| 117 | /// |
no test coverage detected