party_run/runner/
sync_runner.rs1use crate::{
3 party_command::PartyCommand,
4 runner::{command_handler::handle_single_command, run_report::RunReport},
5 schdeuler::CommandBatch,
6 util::make_counter_blue,
7};
8
9use super::run_report::print_status_report;
10
11pub fn run_sync_commands(batches: Vec<CommandBatch>, no_commands: usize) -> anyhow::Result<()> {
13 let mut reports: Vec<RunReport> = vec![];
14 let mut failed = 0;
15
16 let mut curr: usize = 0;
17
18 for batch in batches {
19 assert!(batch.len() == 1);
20
21 let command = &batch[0];
22 curr += 1;
23
24 let report = handle_single_command(make_counter_blue(curr, no_commands), command)?;
25 if !report.success {
26 failed += 1;
27 }
28
29 reports.push(report);
30 }
31
32 print_status_report(failed, no_commands, reports);
33
34 Ok(())
35}
36
37pub fn run_single_command(command: &PartyCommand) -> anyhow::Result<()> {
39 let report = handle_single_command(make_counter_blue(1, 1), command)?;
40
41 let failed = if !report.success { 1 } else { 0 };
42
43 print_status_report(failed, 1, vec![report]);
44 Ok(())
45}