mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 09:46:17 +01:00
tests/sandbox: Use isolated-directories
So we don't have to bother to manually remove the created artifacts.
This commit is contained in:
parent
4ba188c906
commit
660242af07
@ -30,28 +30,24 @@ test_sandbox_none (void)
|
|||||||
static void
|
static void
|
||||||
test_sandbox_snap (void)
|
test_sandbox_snap (void)
|
||||||
{
|
{
|
||||||
gchar *temp_dir, *snap_path, *snap_version_path, *meta_path, *yaml_path;
|
const char *temp_dir;
|
||||||
|
gchar *snap_path, *meta_path, *yaml_path;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
temp_dir = g_dir_make_tmp ("gio-test-sandbox_XXXXXX", &error);
|
temp_dir = g_getenv ("G_TEST_TMPDIR");
|
||||||
g_assert_no_error (error);
|
g_assert_nonnull (temp_dir);
|
||||||
snap_path = g_build_filename (temp_dir, "snap", NULL);
|
|
||||||
snap_version_path = g_build_filename (snap_path, "current", NULL);
|
snap_path = g_build_filename (temp_dir, "snap", "current", NULL);
|
||||||
meta_path = g_build_filename (snap_version_path, "meta", NULL);
|
meta_path = g_build_filename (snap_path, "meta", NULL);
|
||||||
yaml_path = g_build_filename (meta_path, "snap.yaml", NULL);
|
yaml_path = g_build_filename (meta_path, "snap.yaml", NULL);
|
||||||
g_mkdir_with_parents (meta_path, 0700);
|
g_mkdir_with_parents (meta_path, 0700);
|
||||||
g_file_set_contents (yaml_path, "", -1, NULL);
|
g_file_set_contents (yaml_path, "", -1, &error);
|
||||||
g_setenv ("SNAP", snap_version_path, TRUE);
|
g_assert_no_error (error);
|
||||||
|
g_setenv ("SNAP", snap_path, TRUE);
|
||||||
|
|
||||||
g_assert_cmpint (glib_get_sandbox_type (), ==, G_SANDBOX_TYPE_SNAP);
|
g_assert_cmpint (glib_get_sandbox_type (), ==, G_SANDBOX_TYPE_SNAP);
|
||||||
|
|
||||||
g_unsetenv ("SNAP");
|
g_unsetenv ("SNAP");
|
||||||
g_unlink (yaml_path);
|
|
||||||
g_rmdir (meta_path);
|
|
||||||
g_rmdir (snap_version_path);
|
|
||||||
g_rmdir (snap_path);
|
|
||||||
g_rmdir (temp_dir);
|
|
||||||
g_free (temp_dir);
|
|
||||||
g_free (snap_path);
|
g_free (snap_path);
|
||||||
g_free (meta_path);
|
g_free (meta_path);
|
||||||
g_free (yaml_path);
|
g_free (yaml_path);
|
||||||
@ -60,7 +56,7 @@ test_sandbox_snap (void)
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
g_test_init (&argc, &argv, NULL);
|
g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
|
||||||
|
|
||||||
g_test_add_func ("/sandbox/none", test_sandbox_none);
|
g_test_add_func ("/sandbox/none", test_sandbox_none);
|
||||||
g_test_add_func ("/sandbox/snap", test_sandbox_snap);
|
g_test_add_func ("/sandbox/snap", test_sandbox_snap);
|
||||||
|
Loading…
Reference in New Issue
Block a user