Skip to content

Commit

Permalink
fixup! fix(runner): cargo-codspeed compat and double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencaccia committed Dec 4, 2023
1 parent e118e09 commit cb40e8e
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/runner/valgrind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ lazy_static! {
}

fn get_bench_command(config: &Config) -> String {
let mut bench_command = config.command.clone();
bench_command = bench_command
let bench_command = &config.command;
bench_command
// Fixes a compatibility issue with cargo 1.66+ running directly under valgrind <3.20
.replace("cargo codspeed", "cargo-codspeed")
// Escape double quotes since we're going to run this command in a subshell
.replace('"', "\\\"");

format!("\"{}\"", bench_command)
}

pub fn measure(config: &Config, profile_folder: &Path) -> Result<()> {
Expand Down Expand Up @@ -114,9 +110,9 @@ mod tests {
fn test_get_bench_command_cargo() {
let config = Config {
command: "cargo codspeed bench".into(),
..Default::default()
..Config::test()
};
assert_eq!(get_bench_command(&config), "\"cargo-codspeed bench\"");
assert_eq!(get_bench_command(&config), "cargo-codspeed bench");
}

#[test]
Expand All @@ -128,15 +124,15 @@ pnpm vitest bench "my-app"
pytest tests/ --codspeed
"#
.into(),
..Default::default()
..Config::test()
};
assert_eq!(
get_bench_command(&config),
r#""
cargo-codspeed bench --features \"foo bar\"
pnpm vitest bench \"my-app\"
r#"
cargo-codspeed bench --features "foo bar"
pnpm vitest bench "my-app"
pytest tests/ --codspeed
""#
"#
);
}
}

0 comments on commit cb40e8e

Please sign in to comment.