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.
This commit is contained in:
Johannes Altmanninger 2023-09-17 18:02:19 +02:00
parent 618834c4b5
commit 28a38946a5

View File

@ -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)*) => {