MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / build_exec_targets_pipe_command

Function build_exec_targets_pipe_command

src/cli/exec/multi_targets.rs:73–96  ·  view source on GitHub ↗

Build a shell command string that pipes BenchmarkTarget::Exec variants to exec-harness via stdin

(
    targets: &[&crate::executor::config::BenchmarkTarget],
)

Source from the content-addressed store, hash-verified

71
72/// Build a shell command string that pipes BenchmarkTarget::Exec variants to exec-harness via stdin
73pub 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
98fn build_pipe_command_from_json(json: &str) -> String {
99 format!("{EXEC_HARNESS_COMMAND} - <<'CODSPEED_EOF'\n{json}\nCODSPEED_EOF")

Callers 1

executeMethod · 0.85

Calls 1

Tested by

no test coverage detected