diff --git a/gio/tests/portal-support-snap-classic.c b/gio/tests/portal-support-snap-classic.c index 8c0ed90c2..093335d81 100644 --- a/gio/tests/portal-support-snap-classic.c +++ b/gio/tests/portal-support-snap-classic.c @@ -66,6 +66,9 @@ tests_teardown (SetupData *setup_data, else g_unsetenv ("SNAP"); + cleanup_snapfiles (setup_data->snap_path); + cleanup_snapfiles (setup_data->bin_path); + g_clear_pointer (&setup_data->old_path, g_free); g_clear_pointer (&setup_data->old_snap, g_free); } diff --git a/gio/tests/portal-support-snap.c b/gio/tests/portal-support-snap.c index 7dd14d82f..38f85ca65 100644 --- a/gio/tests/portal-support-snap.c +++ b/gio/tests/portal-support-snap.c @@ -67,6 +67,9 @@ tests_teardown (SetupData *setup_data, else g_unsetenv ("SNAP"); + cleanup_snapfiles (setup_data->snap_path); + cleanup_snapfiles (setup_data->bin_path); + g_clear_pointer (&setup_data->old_path, g_free); g_clear_pointer (&setup_data->old_snap, g_free); } diff --git a/gio/tests/portal-support-utils.c b/gio/tests/portal-support-utils.c index ae7073a3a..b7ee22630 100644 --- a/gio/tests/portal-support-utils.c +++ b/gio/tests/portal-support-utils.c @@ -26,6 +26,33 @@ #include #include + +void +cleanup_snapfiles (const gchar *path) +{ + GDir *dir = NULL; + const gchar *entry; + + dir = g_dir_open (path, 0, NULL); + if (dir == NULL) + { + /* Assume it’s a file. Ignore failure. */ + (void) g_remove (path); + return; + } + + while ((entry = g_dir_read_name (dir)) != NULL) + { + gchar *sub_path = g_build_filename (path, entry, NULL); + cleanup_snapfiles (sub_path); + g_free (sub_path); + } + + g_dir_close (dir); + + g_rmdir (path); +} + void create_fake_snapctl (const char *path, const char *supported_op) diff --git a/gio/tests/portal-support-utils.h b/gio/tests/portal-support-utils.h index 40c035b43..defbdcd4e 100644 --- a/gio/tests/portal-support-utils.h +++ b/gio/tests/portal-support-utils.h @@ -23,6 +23,8 @@ #include +void cleanup_snapfiles (const gchar *path); + void create_fake_snap_yaml (const char *snap_path, gboolean is_classic);