(
bridge: &NativeBridge,
udid: &str,
steps: Vec<String>,
file: Option<PathBuf>,
use_stdin: bool,
continue_on_error: bool,
)
| 1 | fn run_batch( |
| 2 | bridge: &NativeBridge, |
| 3 | udid: &str, |
| 4 | steps: Vec<String>, |
| 5 | file: Option<PathBuf>, |
| 6 | use_stdin: bool, |
| 7 | continue_on_error: bool, |
| 8 | ) -> anyhow::Result<Value> { |
| 9 | let step_lines = read_batch_steps(steps, file, use_stdin)?; |
| 10 | let mut results = Vec::new(); |
| 11 | let mut failures = Vec::new(); |
| 12 | for (index, line) in step_lines.iter().enumerate() { |
| 13 | let result = run_batch_step(bridge, udid, line); |
| 14 | match result { |
| 15 | Ok(action) => { |
| 16 | results.push(serde_json::json!({ "index": index, "ok": true, "action": action })) |
| 17 | } |
| 18 | Err(error) => { |
| 19 | let message = error.to_string(); |
| 20 | results.push(serde_json::json!({ "index": index, "ok": false, "error": message })); |
| 21 | failures.push(message); |
| 22 | if !continue_on_error { |
| 23 | return Err(crate::error::AppError::bad_request(format!( |
| 24 | "Batch step {} failed: {}", |
| 25 | index + 1, |
| 26 | failures.last().unwrap() |
| 27 | )) |
| 28 | .into()); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | Ok(serde_json::json!({ |
| 34 | "ok": failures.is_empty(), |
| 35 | "steps": results, |
| 36 | "failureCount": failures.len() |
| 37 | })) |
| 38 | } |
| 39 | |
| 40 | fn read_batch_steps( |
| 41 | steps: Vec<String>, |
no test coverage detected