]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
test_incomplete: Add function
authorSimon McVittie <smcv@collabora.com>
Wed, 31 Oct 2018 15:19:19 +0000 (15:19 +0000)
committerSimon McVittie <smcv@collabora.com>
Wed, 31 Oct 2018 16:56:36 +0000 (16:56 +0000)
This is a wrapper for g_test_incomplete(), which works around bugs in
that function prior to GLib 2.57.3. I originally wrote it for librsvg.

Signed-off-by: Simon McVittie <smcv@collabora.com>
test/test-utils-glib.c
test/test-utils-glib.h

index 3b447fe81bab4fb9679b669dcaa5a9f0b1cbf4a3..930b87dfc1960b97da43db5311f443911e32cb9d 100644 (file)
@@ -863,3 +863,30 @@ test_store_result_cb (GObject *source_object G_GNUC_UNUSED,
   g_assert_null (*result_p);
   *result_p = g_object_ref (result);
 }
+
+/*
+ * Report that a test should have failed, but we are tolerating the
+ * failure because it represents a known bug or missing feature.
+ *
+ * This is the same as g_test_incomplete(), but with a workaround for
+ * GLib bug 1474 so that we don't fail tests on older GLib.
+ */
+void
+test_incomplete (const gchar *message)
+{
+  if (glib_check_version (2, 57, 3))
+    {
+      /* In GLib >= 2.57.3, g_test_incomplete() behaves as intended:
+       * the test result is reported as an expected failure and the
+       * overall test exits 0 */
+      g_test_incomplete (message);
+    }
+  else
+    {
+      /* In GLib < 2.57.3, g_test_incomplete() reported the wrong TAP
+       * result (an unexpected success) and the overall test exited 1,
+       * which would break "make check". g_test_skip() is the next
+       * best thing available. */
+      g_test_skip (message);
+    }
+}
index d36f4301576d794ca6343bff63764463c47a1515..7cfc87856638ac38d30cb9c260883a21e59d8592 100644 (file)
@@ -127,4 +127,6 @@ void test_store_result_cb (GObject *source_object,
                            GAsyncResult *result,
                            gpointer user_data);
 
+void test_incomplete (const gchar *message);
+
 #endif