From 28a38946a5cbd867fe4ee6f0c2c85db36a6a2f6b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 17 Sep 2023 18:02:19 +0200 Subject: [PATCH] common: port err!() test helper Unlike our C++ tests, our Rust tests fail as soon as an assertion fails. Whether this is desired is debatable; it seems fine for most cases and is easier to implement. This means that Rust tests usually don't need to print anything besides what assert!/assert_eq! already provide. One exception is the history merge test. Let's add a simple err!() macro to support this. Unlike the C++ err() it does not yet print colors. Currently all of our macros live in common.rs, to keep the import graph simple. --- fish-rust/src/common.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fish-rust/src/common.rs b/fish-rust/src/common.rs index 4b1c2fd29..f49458a7d 100644 --- a/fish-rust/src/common.rs +++ b/fish-rust/src/common.rs @@ -2108,6 +2108,14 @@ impl ToCString for &[u8] { } } +// test-only +#[allow(unused_macros)] +macro_rules! err { + ($format:expr $(, $args:expr)* $(,)? ) => { + println!($format $(, $args )*); + } +} + #[allow(unused_macros)] macro_rules! fwprintf { ($fd:expr, $format:literal $(, $arg:expr)*) => {