gtestutils: Forbid test paths from containing dots

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 <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/glib/issues/538
This commit is contained in:
Philip Withnall 2018-11-30 17:25:09 +00:00
parent 592365239a
commit 2c8ae9f175

View File

@ -1914,6 +1914,7 @@ g_test_add_vtable (const char *testpath,
g_return_if_fail (testpath != NULL); g_return_if_fail (testpath != NULL);
g_return_if_fail (g_path_is_absolute (testpath)); g_return_if_fail (g_path_is_absolute (testpath));
g_return_if_fail (fixture_test_func != NULL); g_return_if_fail (fixture_test_func != NULL);
g_return_if_fail (!test_isolate_dirs || strstr (testpath, "/.") == NULL);
suite = g_test_get_root(); suite = g_test_get_root();
segments = g_strsplit (testpath, "/", -1); 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 * the test will be skipped by default, and only run if explicitly
* required via the `-p` command-line option or g_test_trap_subprocess(). * 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 isnt.
*
* Since: 2.16 * Since: 2.16
*/ */
void void
@ -2140,6 +2145,10 @@ g_test_add_func (const char *testpath,
* the test will be skipped by default, and only run if explicitly * the test will be skipped by default, and only run if explicitly
* required via the `-p` command-line option or g_test_trap_subprocess(). * 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 isnt.
*
* Since: 2.16 * Since: 2.16
*/ */
void void