Build a shell command string that pipes BenchmarkTarget::Exec variants to exec-harness via stdin
(
targets: &[&crate::executor::config::BenchmarkTarget],
)
| 71 | |
| 72 | /// Build a shell command string that pipes BenchmarkTarget::Exec variants to exec-harness via stdin |
| 73 | pub fn build_exec_targets_pipe_command( |
| 74 | targets: &[&crate::executor::config::BenchmarkTarget], |
| 75 | ) -> Result<String> { |
| 76 | let inputs: Vec<BenchmarkCommand> = targets |
| 77 | .iter() |
| 78 | .map(|target| match target { |
| 79 | crate::executor::config::BenchmarkTarget::Exec { |
| 80 | command, |
| 81 | name, |
| 82 | walltime_args, |
| 83 | } => Ok(BenchmarkCommand { |
| 84 | command: command.clone(), |
| 85 | name: name.clone(), |
| 86 | walltime_args: walltime_args.clone(), |
| 87 | }), |
| 88 | crate::executor::config::BenchmarkTarget::Entrypoint { .. } => { |
| 89 | bail!("Entrypoint targets cannot be used with exec-harness pipe command") |
| 90 | } |
| 91 | }) |
| 92 | .collect::<Result<Vec<_>>>()?; |
| 93 | |
| 94 | let json = serde_json::to_string(&inputs).context("Failed to serialize targets to JSON")?; |
| 95 | Ok(build_pipe_command_from_json(&json)) |
| 96 | } |
| 97 | |
| 98 | fn build_pipe_command_from_json(json: &str) -> String { |
| 99 | format!("{EXEC_HARNESS_COMMAND} - <<'CODSPEED_EOF'\n{json}\nCODSPEED_EOF") |
no test coverage detected