Skip to content

Commit a1b602f

Browse files
committed
honor pairasm binary overrides in benchmarks
Allow the comparative benchmark harness to resolve pairasm from PAIRASM_BIN when it is set in the environment or in benches/config/tools.env. This makes it possible to compare native and portable pairasm builds without the harness unconditionally rebuilding target/release/pairasm. Keep the existing fallback behavior when PAIRASM_BIN is absent: the harness still builds the release pairassembler binary and uses target/release/pairasm. Document the new override in tools.env.example alongside the existing competitor-tool overrides. Remove the stale benches/runs gitignore now that benchmark evidence is treated as local generated output.
1 parent d5c5f94 commit a1b602f

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

‎benches/config/tools.env.example‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copy to benches/config/tools.env or export these variables before running.
22

3+
PAIRASM_BIN="target/release/pairasm"
34
FASTP_BIN="fastp"
45
VSEARCH_BIN="vsearch"
56
BBMERGE_BIN="bbmerge"

‎benches/runs/.gitignore‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎benches/src/config.rs‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ fn env_or_file(key: &str, file_env: &BTreeMap<String, String>) -> Option<String>
236236
env::var(key).ok().or_else(|| file_env.get(key).cloned())
237237
}
238238

239-
fn resolve_pairasm(_file_env: &BTreeMap<String, String>) -> Result<PathBuf> {
239+
fn resolve_pairasm(file_env: &BTreeMap<String, String>) -> Result<PathBuf> {
240+
if env_or_file("PAIRASM_BIN", file_env).is_some() {
241+
return resolve_tool("PAIRASM_BIN", "pairasm", file_env);
242+
}
243+
240244
build_pairasm_release()?;
241245
Ok(PathBuf::from("target/release/pairasm"))
242246
}
@@ -258,7 +262,11 @@ fn resolve_tool(
258262
file_env: &BTreeMap<String, String>,
259263
) -> Result<PathBuf> {
260264
let configured = env_or_file(key, file_env).unwrap_or_else(|| default_name.to_owned());
261-
let path = PathBuf::from(&configured);
265+
resolve_configured_tool(&configured)
266+
}
267+
268+
fn resolve_configured_tool(configured: &str) -> Result<PathBuf> {
269+
let path = PathBuf::from(configured);
262270
if path.components().count() > 1 && path.exists() {
263271
return Ok(path);
264272
}
@@ -329,7 +337,7 @@ mod tests {
329337

330338
use super::Dataset;
331339

332-
use super::{effective_read_pairs, parse_read_pair_cap};
340+
use super::{effective_read_pairs, parse_read_pair_cap, resolve_configured_tool};
333341

334342
#[test]
335343
fn read_pair_cap_parse_accepts_missing_empty_or_positive_integer_values() {
@@ -388,6 +396,30 @@ mod tests {
388396
);
389397
}
390398

399+
#[test]
400+
fn configured_tool_path_accepts_existing_path_with_directory_component() {
401+
let configured = format!("{}/src/config.rs", env!("CARGO_MANIFEST_DIR"));
402+
let resolved = resolve_configured_tool(&configured)
403+
.expect("existing configured tool paths should resolve directly");
404+
405+
assert!(resolved.ends_with("config.rs"));
406+
}
407+
408+
#[test]
409+
fn configured_tool_path_rejects_missing_path_with_directory_component() {
410+
let error = match resolve_configured_tool("definitely/missing/pairasm") {
411+
Ok(_) => panic!("missing configured tool paths should fail"),
412+
Err(error) => error,
413+
};
414+
415+
assert!(
416+
error
417+
.to_string()
418+
.contains("required benchmark tool not found")
419+
);
420+
assert!(error.to_string().contains("definitely/missing/pairasm"));
421+
}
422+
391423
fn dataset_with_cap(read_pair_cap: Option<NonZeroUsize>) -> Dataset {
392424
Dataset {
393425
name: "dataset".to_owned(),

0 commit comments

Comments
 (0)