From 65ee7c28283dc616bbc1ad029ad41a7a2a01c90b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 18 Sep 2025 11:28:24 -0500 Subject: [PATCH] fix(harness): Make the usage's bin relative to current_dir --- crates/libtest2-harness/src/harness.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/libtest2-harness/src/harness.rs b/crates/libtest2-harness/src/harness.rs index dd443f2..18555d0 100644 --- a/crates/libtest2-harness/src/harness.rs +++ b/crates/libtest2-harness/src/harness.rs @@ -205,6 +205,11 @@ fn parse<'p>(parser: &mut cli::Parser<'p>) -> Result { + let mut bin = std::path::Path::new(bin); + if let Ok(current_dir) = std::env::current_dir() { + // abbreviate the path because cargo always uses absolute paths + bin = bin.strip_prefix(¤t_dir).unwrap_or(bin); + } let bin = bin.to_string_lossy(); let options_help = libtest_lexarg::OPTIONS_HELP.trim(); let after_help = libtest_lexarg::AFTER_HELP.trim();