summaryrefslogtreecommitdiff
path: root/egg
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2021-01-15 20:46:18 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2021-01-15 20:46:18 +0100
commit9c65f7dae1cc2468165bc9e1637e65da92df1c51 (patch)
tree5a711b2eaac4ad6d4e6539c891e291a3a4f4b8c9 /egg
parentcc6624e520637fd8493b9402da073cf8c859e988 (diff)
downloadgcr-9c65f7dae1cc2468165bc9e1637e65da92df1c51.tar.gz
Create a workaround for tests and GTaskwip/nielsdg/fix-tests-with-racy-gtask
It's possible that a GTask that has been called with `g_task_run_in_thread()` still has a reference held by that thread after the `_finish()` function has been called. This is a little problematic for tests that check for the final reference, so use this as a workaround instead. See https://gitlab.gnome.org/GNOME/glib/-/issues/1346 for more info
Diffstat (limited to 'egg')
-rw-r--r--egg/egg-testing.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/egg/egg-testing.h b/egg/egg-testing.h
index 73939b3..a98a782 100644
--- a/egg/egg-testing.h
+++ b/egg/egg-testing.h
@@ -61,4 +61,17 @@ gboolean egg_test_wait_until (int timeout);
gint egg_tests_run_with_loop (void);
+/* It's possible that a GTask that has been called with g_task_run_in_thread()
+ * still has a reference held by that thread after the _finish() function has
+ * been called. This is a little problematic for tests that check for the
+ * final reference, so use this as a workaround instead.
+ *
+ * See https://gitlab.gnome.org/GNOME/glib/-/issues/1346 for more info
+ */
+#define egg_test_wait_for_gtask_thread(expr) G_STMT_START \
+ while (expr) { \
+ g_main_context_iteration (NULL, FALSE); \
+ } \
+ G_STMT_END
+
#endif /* EGG_DH_H_ */