Skip to content

Commit

Permalink
tests: Call g_test_init() before isolated_test_dir_global_setup()
Browse files Browse the repository at this point in the history
g_test_init() is meant to be called before any other use of GTest APIs,
and isolated_test_dir_global_setup() can call g_test_message(). GLib
2.76 makes this more of a practical problem.

(isolated_test_dir_global_setup() is essentially a reimplementation of
G_TEST_OPTION_ISOLATE_DIRS, since we don't depend on GLib 2.60.)

Alternative to #5355.

Signed-off-by: Simon McVittie <smcv@collabora.com>
  • Loading branch information
smcv committed Mar 17, 2023
1 parent 3198321 commit a058d96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions tests/test-exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,9 +1477,8 @@ main (int argc, char *argv[])
/* Do not call setlocale() here: some tests look at untranslated error
* messages. */

isolated_test_dir_global_setup ();

g_test_init (&argc, &argv, NULL);
isolated_test_dir_global_setup ();

g_test_add_func ("/context/empty", test_empty_context);
g_test_add_func ("/context/filesystems", test_filesystems);
Expand Down
3 changes: 1 addition & 2 deletions tests/test-instance.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,8 @@ main (int argc, char *argv[])
{
int res;

isolated_test_dir_global_setup ();

g_test_init (&argc, &argv, NULL);
isolated_test_dir_global_setup ();

g_test_add_func ("/instance/gc", test_gc);
g_test_add_func ("/instance/claim-per-app-temp-directory",
Expand Down

0 comments on commit a058d96

Please sign in to comment.