From 2c8ae9f175ef1047de040e344cc2604a7fc3296d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 30 Nov 2018 17:25:09 +0000 Subject: [PATCH] gtestutils: Forbid test paths from containing dots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to make some guarantees in an upcoming commit that test path components won’t clash with file system names used by GLib, add a restriction that test path components cannot start with a dot. This is an API break, but one which anyone is unlikely to have hit. If it is an issue, we can relax the restriction to be a warning. Signed-off-by: Philip Withnall https://gitlab.gnome.org/GNOME/glib/issues/538 --- glib/gtestutils.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 72f62af19..29618d733 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -1914,6 +1914,7 @@ g_test_add_vtable (const char *testpath, g_return_if_fail (testpath != NULL); g_return_if_fail (g_path_is_absolute (testpath)); g_return_if_fail (fixture_test_func != NULL); + g_return_if_fail (!test_isolate_dirs || strstr (testpath, "/.") == NULL); suite = g_test_get_root(); segments = g_strsplit (testpath, "/", -1); @@ -2102,6 +2103,10 @@ g_test_set_nonfatal_assertions (void) * the test will be skipped by default, and only run if explicitly * required via the `-p` command-line option or g_test_trap_subprocess(). * + * No component of @testpath may start with a dot (`.`) if the + * %G_TEST_OPTION_ISOLATE_DIRS option is being used; and it is recommended to + * do so even if it isn’t. + * * Since: 2.16 */ void @@ -2140,6 +2145,10 @@ g_test_add_func (const char *testpath, * the test will be skipped by default, and only run if explicitly * required via the `-p` command-line option or g_test_trap_subprocess(). * + * No component of @testpath may start with a dot (`.`) if the + * %G_TEST_OPTION_ISOLATE_DIRS option is being used; and it is recommended to + * do so even if it isn’t. + * * Since: 2.16 */ void