diff options
author | Stef Walter <stefw@gnome.org> | 2014-03-06 10:51:58 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2014-03-06 16:46:20 +0100 |
commit | a2ebd3ca4f7569baeeac0b917a057e0392d15412 (patch) | |
tree | 3c4546a9c20891b3b45a56daa6d85fdd218860a9 /egg | |
parent | 0e3cf35b6d5b899897367d6db637b3294dd5bf7d (diff) | |
download | gnome-keyring-a2ebd3ca4f7569baeeac0b917a057e0392d15412.tar.gz |
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.
Diffstat (limited to 'egg')
-rw-r--r-- | 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 adca6030..0fc72f8f 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); } |