File: tests-Move-user-special-dirs-test-from-utils-isolated.c-t.patch

package info (click to toggle)
glib2.0 2.86.0-6
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 74,852 kB
  • sloc: ansic: 544,570; python: 9,702; sh: 1,612; xml: 1,482; perl: 1,222; cpp: 535; makefile: 321; javascript: 11
file content (179 lines) | stat: -rw-r--r-- 6,837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
From: Philip Withnall <pwithnall@gnome.org>
Date: Thu, 18 Sep 2025 16:14:27 +0100
Subject: tests: Move user-special-dirs test from utils-isolated.c to utils.c

`utils-isolated.c` is meant for testing the behaviour of
`G_TEST_OPTION_ISOLATE_DIRS`, not testing the general behaviour of
`gutils.c`. My mistake for not noticing this at code review time when
the test was added.

This introduces no functional changes, just moves a test around.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Origin: upstream, 2.86.1, commit:66aee5e2c85d617c4632fc157ff7a93381f997dc
---
 glib/tests/utils-isolated.c | 58 -------------------------------------------
 glib/tests/utils.c          | 60 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 58 deletions(-)

diff --git a/glib/tests/utils-isolated.c b/glib/tests/utils-isolated.c
index fa14076..beb6e56 100644
--- a/glib/tests/utils-isolated.c
+++ b/glib/tests/utils-isolated.c
@@ -186,63 +186,6 @@ test_cleanup_doesnt_follow_symlinks (void)
 #endif
 }
 
-static void
-test_load_user_special_dirs_unlocked (void)
-{
-#if defined(HAVE_COCOA) || defined(G_OS_WIN32)
-  g_test_skip ("The user-dirs.dirs parser is not used on this platform.");
-#else
-  g_test_summary ("Tests error and corner cases of user-dirs.dirs content.");
-  g_test_bug ("https://gitlab.gnome.org/GNOME/glib/merge_requests/4800");
-
-  if (g_test_subprocess ())
-    {
-      gchar *user_dirs_file;
-      const gchar *config_dir;
-      const gchar *dir;
-      gchar *expected;
-      gboolean result;
-
-      config_dir = g_get_user_config_dir ();
-      user_dirs_file = g_build_filename (config_dir, "user-dirs.dirs", NULL);
-      g_mkdir_with_parents (g_path_get_dirname (user_dirs_file), 0700);
-      result = g_file_set_contents (user_dirs_file,
-                                    "XDG_DESKTOP_DIR = \"/root\"\nXDG_DESKTOP_DIR = \"$HOMER/Desktop\"\n"
-                                    "XDG_DOCUMENTS_DIR = \"$HOME\"\n"
-                                    "XDG_DOWNLOAD_DIR = \"$HOME/Downloads\"\n"
-                                    "XDG_MUSIC_DIR = \"///\"\n"
-                                    "XDG_PICTURES_DIR = \"/\"\nXDG_DOWNLOAD_DIR = \"/dev/null\n",
-                                    -1, NULL);
-      g_assert_true (result);
-      g_free (user_dirs_file);
-
-      g_reload_user_special_dirs_cache ();
-
-      dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
-      g_assert_cmpstr (dir, ==, "/root");
-
-      dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
-      g_assert_cmpstr (dir, ==, g_get_home_dir ());
-
-      expected = g_build_filename (g_get_home_dir (), "Downloads", NULL);
-      dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
-      g_assert_cmpstr (dir, ==, expected);
-      g_free (expected);
-
-      dir = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
-      g_assert_cmpstr (dir, ==, "/");
-
-      dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
-      g_assert_cmpstr (dir, ==, "/");
-    }
-  else
-    {
-      g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_DEFAULT);
-      g_test_trap_assert_passed ();
-    }
-#endif
-}
-
 int
 main (int   argc,
       char *argv[])
@@ -255,7 +198,6 @@ main (int   argc,
 
   g_test_add_func ("/utils-isolated/tmp-dir", test_tmp_dir);
   g_test_add_func ("/utils-isolated/home-dir", test_home_dir);
-  g_test_add_func ("/utils-isolated/load-user-special-dirs-unlocked", test_load_user_special_dirs_unlocked);
   g_test_add_func ("/utils-isolated/user-cache-dir", test_user_cache_dir);
   g_test_add_func ("/utils-isolated/system-config-dirs", test_system_config_dirs);
   g_test_add_func ("/utils-isolated/user-config-dir", test_user_config_dir);
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index 97148b8..0423bfc 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -23,6 +23,8 @@
  * Author: Matthias Clasen
  */
 
+#include "config.h"
+
 #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
 #define GLIB_DISABLE_DEPRECATION_WARNINGS
 #endif
@@ -842,6 +844,63 @@ test_desktop_special_dir (void)
   g_assert_nonnull (dir2);
 }
 
+static void
+test_user_special_dirs_load_unlocked (void)
+{
+#if defined(HAVE_COCOA) || defined(G_OS_WIN32)
+  g_test_skip ("The user-dirs.dirs parser is not used on this platform.");
+#else
+  g_test_summary ("Tests error and corner cases of user-dirs.dirs content.");
+  g_test_bug ("https://gitlab.gnome.org/GNOME/glib/merge_requests/4800");
+
+  if (g_test_subprocess ())
+    {
+      gchar *user_dirs_file;
+      const gchar *config_dir;
+      const gchar *dir;
+      gchar *expected;
+      gboolean result;
+
+      config_dir = g_get_user_config_dir ();
+      user_dirs_file = g_build_filename (config_dir, "user-dirs.dirs", NULL);
+      g_mkdir_with_parents (g_path_get_dirname (user_dirs_file), 0700);
+      result = g_file_set_contents (user_dirs_file,
+                                    "XDG_DESKTOP_DIR = \"/root\"\nXDG_DESKTOP_DIR = \"$HOMER/Desktop\"\n"
+                                    "XDG_DOCUMENTS_DIR = \"$HOME\"\n"
+                                    "XDG_DOWNLOAD_DIR = \"$HOME/Downloads\"\n"
+                                    "XDG_MUSIC_DIR = \"///\"\n"
+                                    "XDG_PICTURES_DIR = \"/\"\nXDG_DOWNLOAD_DIR = \"/dev/null\n",
+                                    -1, NULL);
+      g_assert_true (result);
+      g_free (user_dirs_file);
+
+      g_reload_user_special_dirs_cache ();
+
+      dir = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
+      g_assert_cmpstr (dir, ==, "/root");
+
+      dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+      g_assert_cmpstr (dir, ==, g_get_home_dir ());
+
+      expected = g_build_filename (g_get_home_dir (), "Downloads", NULL);
+      dir = g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD);
+      g_assert_cmpstr (dir, ==, expected);
+      g_free (expected);
+
+      dir = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
+      g_assert_cmpstr (dir, ==, "/");
+
+      dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+      g_assert_cmpstr (dir, ==, "/");
+    }
+  else
+    {
+      g_test_trap_subprocess (NULL, 0, G_TEST_SUBPROCESS_DEFAULT);
+      g_test_trap_assert_passed ();
+    }
+#endif
+}
+
 static void
 test_os_info (void)
 {
@@ -1308,6 +1367,7 @@ main (int   argc,
   g_test_add_func ("/utils/hostname", test_hostname);
   g_test_add_func ("/utils/specialdir", test_special_dir);
   g_test_add_func ("/utils/specialdir/desktop", test_desktop_special_dir);
+  g_test_add_func ("/utils/user-special-dirs/load-unlocked", test_user_special_dirs_load_unlocked);
   g_test_add_func ("/utils/os-info", test_os_info);
   g_test_add_func ("/utils/clear-pointer", test_clear_pointer);
   g_test_add_func ("/utils/clear-pointer-cast", test_clear_pointer_cast);