Skip to content

Commit 2111fb4

Browse files
authored
fix(harness): Make the usage's bin relative to current_dir (#127)
2 parents 07c15f5 + 65ee7c2 commit 2111fb4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/libtest2-harness/src/harness.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ fn parse<'p>(parser: &mut cli::Parser<'p>) -> Result<libtest_lexarg::TestOpts, c
205205
while let Some(arg) = parser.next_arg() {
206206
match arg {
207207
cli::Arg::Short("h") | cli::Arg::Long("help") => {
208+
let mut bin = std::path::Path::new(bin);
209+
if let Ok(current_dir) = std::env::current_dir() {
210+
// abbreviate the path because cargo always uses absolute paths
211+
bin = bin.strip_prefix(&current_dir).unwrap_or(bin);
212+
}
208213
let bin = bin.to_string_lossy();
209214
let options_help = libtest_lexarg::OPTIONS_HELP.trim();
210215
let after_help = libtest_lexarg::AFTER_HELP.trim();

0 commit comments

Comments
 (0)