[glib] gio/tests/file: skip the file monitor tests if using GPollFileMonitor



commit 26f1e0938eeb61c7f93b651aa316e33f3b0d6292
Author: Dan Winship <danw gnome org>
Date:   Fri Feb 3 11:35:26 2012 -0500

    gio/tests/file: skip the file monitor tests if using GPollFileMonitor
    
    test_create_delete() assumes that if it creates a file and then
    immediately deletes it, that the file monitor will notice this and
    record it as a create followed by a delete. But that won't work with
    GPollFileMonitor, which will just think nothing changed. So skip the
    test in that case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669331

 gio/tests/file.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/gio/tests/file.c b/gio/tests/file.c
index 5fed88b..c707d0d 100644
--- a/gio/tests/file.c
+++ b/gio/tests/file.c
@@ -420,6 +420,17 @@ test_create_delete (gconstpointer d)
   error = NULL;
   data->monitor = g_file_monitor_file (data->file, 0, NULL, &error);
   g_assert_no_error (error);
+
+  /* This test doesn't work with GPollFileMonitor, because it assumes
+   * that the monitor will notice a create immediately followed by a
+   * delete, rather than coalescing them into nothing.
+   */
+  if (!strcmp (G_OBJECT_TYPE_NAME (data->monitor), "GPollFileMonitor"))
+    {
+      g_print ("skipping test for this GFileMonitor implementation");
+      goto skip;
+    }
+
   g_file_monitor_set_rate_limit (data->monitor, 100);
 
   g_signal_connect (data->monitor, "changed", G_CALLBACK (monitor_changed), data);
@@ -441,9 +452,11 @@ test_create_delete (gconstpointer d)
   g_assert (g_file_monitor_is_cancelled (data->monitor));
 
   g_main_loop_unref (data->loop);
-  g_object_unref (data->monitor);
   g_object_unref (data->ostream);
   g_object_unref (data->istream);
+
+ skip:
+  g_object_unref (data->monitor);
   g_object_unref (data->file);
   free (data->monitor_path);
   g_free (data->buffer);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]