summaryrefslogtreecommitdiff
path: root/glib/gtestutils.h
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-08-17 15:18:29 -0400
committerMatthias Clasen <mclasen@redhat.com>2013-08-17 17:25:57 -0400
commita6a87506877939fee54bdc7eca70d47fc7d893d4 (patch)
tree88c78dd6d19de9ca1f374651bdc5bee640331eac /glib/gtestutils.h
parentb63739e60ea03364a7a06e0c697b5c6c4690d0b6 (diff)
downloadglib-a6a87506877939fee54bdc7eca70d47fc7d893d4.tar.gz
Add a way to make assertions non-fatal
When using test harnesses other than gtester (e.g. using TAP), it can be suboptimal to have the very first failed assertion abort the test suite. This commit adds a g_test_set_nonfatal_assertions() that can be called in a test binary to change the behaviour of most assert macros to just call g_test_fail() and continue. We don't change the behavior of g_assert() and g_assert_not_reached(), since these to assertion macros are older than GTest, are widely used outside of testsuites, and will cause compiler warnings if they loose their noreturn annotation. https://bugzilla.gnome.org/show_bug.cgi?id=692125
Diffstat (limited to 'glib/gtestutils.h')
-rw-r--r--glib/gtestutils.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 65a8c0987..889df44ac 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -148,6 +148,8 @@ GLIB_AVAILABLE_IN_2_38
void g_test_skip (const gchar *msg);
GLIB_AVAILABLE_IN_2_38
gboolean g_test_failed (void);
+GLIB_AVAILABLE_IN_2_38
+void g_test_set_nonfatal_assertions (void);
/* hook up a test with fixture under test path */
#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
@@ -265,7 +267,7 @@ void g_assertion_message (const char *domain,
const char *file,
int line,
const char *func,
- const char *message) G_GNUC_NORETURN;
+ const char *message);
GLIB_AVAILABLE_IN_ALL
void g_assertion_message_expr (const char *domain,
const char *file,
@@ -280,7 +282,7 @@ void g_assertion_message_cmpstr (const char *domain,
const char *expr,
const char *arg1,
const char *cmp,
- const char *arg2) G_GNUC_NORETURN;
+ const char *arg2);
GLIB_AVAILABLE_IN_ALL
void g_assertion_message_cmpnum (const char *domain,
const char *file,
@@ -290,7 +292,7 @@ void g_assertion_message_cmpnum (const char *domain,
long double arg1,
const char *cmp,
long double arg2,
- char numtype) G_GNUC_NORETURN;
+ char numtype);
GLIB_AVAILABLE_IN_ALL
void g_assertion_message_error (const char *domain,
const char *file,
@@ -299,7 +301,7 @@ void g_assertion_message_error (const char *domain,
const char *expr,
const GError *error,
GQuark error_domain,
- int error_code) G_GNUC_NORETURN;
+ int error_code);
GLIB_AVAILABLE_IN_ALL
void g_test_add_vtable (const char *testpath,
gsize data_size,