From 9055a2043ccb6741d703e4f9b1dcf7d9e5cf07e5 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Sat, 14 Feb 2026 01:54:16 +0100 Subject: [PATCH] cli-test: Add placeholder for executable extension Help text generated by `clap` contains the full file name (including extension) of the binary. On Unix-like systems, binaries commonly do not have any file extension. On Windows, ".exe" is common. To allow testing such output, introduce a new marker "[EXE]" that is substituted accordingly. The idea and syntax is taken from https://docs.rs/trycmd/1.0.0/trycmd/#toml --- crates/radicle-cli-test/src/lib.rs | 10 ++++++++++ crates/radicle-cli/examples/rad-help.md | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/radicle-cli-test/src/lib.rs b/crates/radicle-cli-test/src/lib.rs index 6ce34769..7199a5bf 100644 --- a/crates/radicle-cli-test/src/lib.rs +++ b/crates/radicle-cli-test/src/lib.rs @@ -481,6 +481,16 @@ impl TestFormula { let assert = OutputAssert::new(output).with_assert(assert.clone()); let expected = Self::map_spaced_brackets(&assertion.expected); + let expected = { + #[cfg(windows)] + const EXE: &str = ".exe"; + + #[cfg(unix)] + const EXE: &str = ""; + + expected.replace("[EXE]", EXE) + }; + let matches = if test.stderr { assert.stderr_matches(&expected) } else { diff --git a/crates/radicle-cli/examples/rad-help.md b/crates/radicle-cli/examples/rad-help.md index b997c19f..5d82c322 100644 --- a/crates/radicle-cli/examples/rad-help.md +++ b/crates/radicle-cli/examples/rad-help.md @@ -9,7 +9,7 @@ Do you have feedback? - Mail (Messages are automatically posted to the public #feedback channel on Zulip.) -Usage: rad +Usage: rad[EXE] Commands: auth Manage identities and profiles