From dd48e78652079556bebfe930caad2efa09656584 Mon Sep 17 00:00:00 2001 From: Phaedrus Leeds Date: Thu, 14 Oct 2021 17:38:19 -0700 Subject: [PATCH] testlibrary: Make remote existence assertions more friendly Currently the output produced when assert_remote_in_installation() or assert_remote_not_in_installation() fails is not helpful: it doesn't mention the remote name or where the assertion was called from. Fix those problems by rewriting it as a #define. --- tests/testlibrary.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 459582f0..28d68050 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -3448,19 +3448,21 @@ _is_remote_in_installation (FlatpakInstallation *installation, return FALSE; } -static void -assert_remote_in_installation (FlatpakInstallation *installation, - const char *remote_name) -{ - g_assert_true (_is_remote_in_installation (installation, remote_name)); -} +#define assert_remote_in_installation(inst, remote) \ + G_STMT_START { \ + if (!_is_remote_in_installation (inst, remote)) \ + g_assertion_message (G_LOG_DOMAIN, \ + __FILE__, __LINE__, G_STRFUNC, \ + "remote " remote " not found"); \ + } G_STMT_END -static void -assert_remote_not_in_installation (FlatpakInstallation *installation, - const char *remote_name) -{ - g_assert_true (!_is_remote_in_installation (installation, remote_name)); -} +#define assert_remote_not_in_installation(inst, remote) \ + G_STMT_START { \ + if (_is_remote_in_installation (inst, remote)) \ + g_assertion_message (G_LOG_DOMAIN, \ + __FILE__, __LINE__, G_STRFUNC, \ + "remote " remote " was found"); \ + } G_STMT_END static gboolean add_new_remote3 (FlatpakTransaction *transaction,