mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
Add macros for all g_test_init options
Add macros, and use them.
This commit is contained in:
parent
90f4e562be
commit
b161cb9252
@ -1637,12 +1637,14 @@ test_rm_isolate_dirs (void)
|
||||
*
|
||||
* Options which can be passed to @... are:
|
||||
*
|
||||
* - `"no_g_set_prgname"`: Causes g_test_init() to not call g_set_prgname().
|
||||
* - %G_TEST_OPTION_ISOLATE_DIRS: Creates a unique temporary directory for each
|
||||
* - `G_TEST_OPTION_NO_PRGNAME`: Causes g_test_init() to not call
|
||||
* [func@GLib.set_prgname]. Since. 2.84
|
||||
* - `G_TEST_OPTION_ISOLATE_DIRS`: Creates a unique temporary directory for each
|
||||
* unit test and uses g_set_user_dirs() to set XDG directories to point into
|
||||
* that temporary directory for the duration of the unit test. See the
|
||||
* documentation for %G_TEST_OPTION_ISOLATE_DIRS.
|
||||
* - "nonfatal-assertions": This has the same effect as [func@GLib.test_set_nonfatal_assertions]. Since 2.82
|
||||
* - `G_TEST_OPTION_NONFATAL_ASSERTIONS`: This has the same effect as
|
||||
* [func@GLib.test_set_nonfatal_assertions]. Since 2.84
|
||||
*
|
||||
* Since 2.58, if tests are compiled with `G_DISABLE_ASSERT` defined,
|
||||
* g_test_init() will print an error and exit. This is to prevent no-op tests
|
||||
@ -1697,11 +1699,11 @@ void
|
||||
va_start (args, argv);
|
||||
while ((option = va_arg (args, char *)))
|
||||
{
|
||||
if (g_strcmp0 (option, "no_g_set_prgname") == 0)
|
||||
if (g_strcmp0 (option, G_TEST_OPTION_NO_PRGNAME) == 0)
|
||||
no_g_set_prgname = TRUE;
|
||||
else if (g_strcmp0 (option, G_TEST_OPTION_ISOLATE_DIRS) == 0)
|
||||
test_isolate_dirs = TRUE;
|
||||
else if (g_strcmp0 (option, "nonfatal-assertions") == 0)
|
||||
else if (g_strcmp0 (option, G_TEST_OPTION_NONFATAL_ASSERTIONS) == 0)
|
||||
test_nonfatal_assertions = TRUE;
|
||||
}
|
||||
va_end (args);
|
||||
|
@ -302,6 +302,8 @@ void g_test_init (int *argc,
|
||||
/**
|
||||
* G_TEST_OPTION_ISOLATE_DIRS:
|
||||
*
|
||||
* A value that can be passed as an option to [func@GLib.test_init].
|
||||
*
|
||||
* Creates a unique temporary directory for each unit test and uses
|
||||
* g_set_user_dirs() to set XDG directories to point into subdirectories of it
|
||||
* for the duration of the unit test. The directory tree is cleaned up after the
|
||||
@ -330,6 +332,29 @@ void g_test_init (int *argc,
|
||||
*/
|
||||
#define G_TEST_OPTION_ISOLATE_DIRS "isolate_dirs"
|
||||
|
||||
/**
|
||||
* G_TEST_OPTION_NO_PRGNAME:
|
||||
*
|
||||
* A value that can be passed as an option to [func@GLib.test_init].
|
||||
*
|
||||
* If this option is given, [func@GLib.test_init] will not call [func@GLib.set_prgname].
|
||||
*
|
||||
* Since: 2.84
|
||||
*/
|
||||
#define G_TEST_OPTION_NO_PRGNAME "no_g_set_prgname"
|
||||
|
||||
/**
|
||||
* G_TEST_OPTION_NONFATAL_ASSERTIONS:
|
||||
*
|
||||
* A value that can be passed as an option to [func@GLib.test_init].
|
||||
*
|
||||
* If this option is given, assertions will not abort the process, but
|
||||
* call [func@GLib.test_fail]. Equivalent to [func@GLib.test_set_nonfatal_assertions].
|
||||
*
|
||||
* Since: 2.84
|
||||
*/
|
||||
#define G_TEST_OPTION_NONFATAL_ASSERTIONS "nonfatal-assertions"
|
||||
|
||||
/* While we discourage its use, g_assert() is often used in unit tests
|
||||
* (especially in legacy code). g_assert_*() should really be used instead.
|
||||
* g_assert() can be disabled at client program compile time, which can render
|
||||
|
Loading…
x
Reference in New Issue
Block a user