[gnome-keyring] egg: Support nested directories in egg_tests_remove_scratch_directory()



commit a2ebd3ca4f7569baeeac0b917a057e0392d15412
Author: Stef Walter <stefw gnome org>
Date:   Thu Mar 6 10:51:58 2014 +0100

    egg: Support nested directories in egg_tests_remove_scratch_directory()
    
    Call 'rm' to cleanup the directory instead of removing files ourselves.
    We want to use nested directories in some tests.

 egg/egg-testing.c |   24 ++++++++----------------
 1 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/egg/egg-testing.c b/egg/egg-testing.c
index adca603..0fc72f8 100644
--- a/egg/egg-testing.c
+++ b/egg/egg-testing.c
@@ -285,23 +285,15 @@ egg_tests_create_scratch_directory (const gchar *file_to_copy,
 void
 egg_tests_remove_scratch_directory (const gchar *directory)
 {
-       GDir *dir;
+       gchar *argv[] = { "rm", "-r", (gchar *)directory, NULL };
        GError *error = NULL;
-       const gchar *name;
-       gchar *filename;
+       gint rm_status;
 
-       dir = g_dir_open (directory, 0, &error);
-       g_assert_no_error (error);
-
-       while ((name = g_dir_read_name (dir)) != NULL) {
-               filename = g_build_filename (directory, name, NULL);
-               if (g_unlink (filename) < 0)
-                       g_assert_not_reached ();
-               g_free (filename);
-       }
+       g_assert_cmpstr (directory, !=, "");
+       g_assert_cmpstr (directory, !=, "/");
 
-       g_dir_close (dir);
-
-       if (g_rmdir (directory) < 0)
-               g_assert_not_reached ();
+       g_spawn_sync (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL,
+                     NULL, NULL, NULL, &rm_status, &error);
+       g_assert_no_error (error);
+       g_assert_cmpint (rm_status, ==, 0);
 }


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