mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Merge branch 'wip/smcv/defer-test-cleanup' into 'main'
testutils: Defer global cleanup until we really exit Closes #2563 See merge request GNOME/glib!2420
This commit is contained in:
commit
1094bfc7d7
@ -890,10 +890,10 @@ static gboolean test_debug_log = FALSE;
|
||||
static gboolean test_tap_log = TRUE; /* default to TAP as of GLib 2.62; see #1619; the non-TAP output mode is deprecated */
|
||||
static gboolean test_nonfatal_assertions = FALSE;
|
||||
static DestroyEntry *test_destroy_queue = NULL;
|
||||
static char *test_argv0 = NULL;
|
||||
static char *test_argv0_dirname;
|
||||
static const char *test_disted_files_dir;
|
||||
static const char *test_built_files_dir;
|
||||
static const char *test_argv0 = NULL; /* points into global argv */
|
||||
static char *test_argv0_dirname = NULL; /* owned by GLib */
|
||||
static const char *test_disted_files_dir; /* points into test_argv0_dirname or an environment variable */
|
||||
static const char *test_built_files_dir; /* points into test_argv0_dirname or an environment variable */
|
||||
static char *test_initial_cwd = NULL;
|
||||
static gboolean test_in_forked_child = FALSE;
|
||||
static gboolean test_in_subprocess = FALSE;
|
||||
@ -2220,6 +2220,13 @@ g_test_run (void)
|
||||
int ret;
|
||||
GTestSuite *suite;
|
||||
|
||||
if (atexit (test_cleanup) != 0)
|
||||
{
|
||||
int errsv = errno;
|
||||
g_error ("Unable to register test cleanup to be run at exit: %s",
|
||||
g_strerror (errsv));
|
||||
}
|
||||
|
||||
suite = g_test_get_root ();
|
||||
if (g_test_run_suite (suite) != 0)
|
||||
{
|
||||
@ -2256,7 +2263,6 @@ g_test_run (void)
|
||||
|
||||
out:
|
||||
g_test_suite_free (suite);
|
||||
test_cleanup ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3823,7 +3829,7 @@ g_test_trap_subprocess (const char *test_path,
|
||||
test_trap_last_subprocess = g_strdup (test_path);
|
||||
|
||||
argv = g_ptr_array_new ();
|
||||
g_ptr_array_add (argv, test_argv0);
|
||||
g_ptr_array_add (argv, (char *) test_argv0);
|
||||
g_ptr_array_add (argv, "-q");
|
||||
g_ptr_array_add (argv, "-p");
|
||||
g_ptr_array_add (argv, (char *)test_path);
|
||||
|
@ -1589,12 +1589,19 @@ int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
int ret;
|
||||
char *filename, *filename2;
|
||||
|
||||
argv0 = argv[0];
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
/* Part of a test for
|
||||
* https://gitlab.gnome.org/GNOME/glib/-/issues/2563, see below */
|
||||
filename = g_test_build_filename (G_TEST_BUILT, "nonexistent", NULL);
|
||||
|
||||
g_test_add_func ("/random-generator/rand-1", test_rand1);
|
||||
g_test_add_func ("/random-generator/rand-2", test_rand2);
|
||||
g_test_add_func ("/random-generator/random-conversions", test_random_conversions);
|
||||
@ -1675,5 +1682,16 @@ main (int argc,
|
||||
g_test_add_func ("/tap", test_tap);
|
||||
g_test_add_func ("/tap/summary", test_tap_summary);
|
||||
|
||||
return g_test_run();
|
||||
ret = g_test_run ();
|
||||
|
||||
/* We can't test for https://gitlab.gnome.org/GNOME/glib/-/issues/2563
|
||||
* from a test-case, because the whole point of that issue is that it's
|
||||
* about whether certain patterns are valid after g_test_run() has
|
||||
* returned... so put an ad-hoc test here, and just crash if it fails. */
|
||||
filename2 = g_test_build_filename (G_TEST_BUILT, "nonexistent", NULL);
|
||||
g_assert_cmpstr (filename, ==, filename2);
|
||||
|
||||
g_free (filename);
|
||||
g_free (filename2);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user