Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Don't use g_test_message before g_test_init #5355

Closed
wants to merge 1 commit into from

Conversation

heftig
Copy link
Contributor

@heftig heftig commented Mar 17, 2023

Meson will fail a test using TAP if the first line on stdout isn't the TAP version declaration.

Meson will fail a test using TAP if the first line on stdout isn't the
TAP version declaration.
@heftig
Copy link
Contributor Author

heftig commented Mar 17, 2023

This seems to be caused by changes to gtestutils in GLib 2.76. Maybe GLib needs to ensure the TAP version line is printed first even if a test binary is using g_test_message before calling g_test_init.

@heftig
Copy link
Contributor Author

heftig commented Mar 17, 2023

Copy link
Collaborator

@pwithnall pwithnall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change as written will cause TAP output formatting to be broken, as these messages will now be printed without a leading # . If that’s something flatpak cares about, the PR will need reworking.

Can’t the test be changed to definitely call g_test_init() first?

smcv added a commit to smcv/flatpak that referenced this pull request Mar 17, 2023
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 flatpak#5355.

Signed-off-by: Simon McVittie <smcv@collabora.com>
@smcv
Copy link
Collaborator

smcv commented Mar 17, 2023

This change as written will cause TAP output formatting to be broken, as these messages will now be printed without a leading # .

g_printerr() writes to stderr, which is out-of-scope for TAP consumers (they only parse stdout), so that part at least is not a problem.

Can’t the test be changed to definitely call g_test_init() first?

I think that's a better solution, though. #5358

smcv added a commit to smcv/flatpak that referenced this pull request Mar 17, 2023
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 flatpak#5355.

Signed-off-by: Simon McVittie <smcv@collabora.com>
@smcv
Copy link
Collaborator

smcv commented Mar 17, 2023

I think #5358 is a better solution.

@smcv smcv closed this Mar 17, 2023
smcv added a commit to smcv/flatpak that referenced this pull request Mar 17, 2023
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 flatpak#5355.

Signed-off-by: Simon McVittie <smcv@collabora.com>
smcv added a commit that referenced this pull request Mar 17, 2023
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>
smcv added a commit to smcv/flatpak that referenced this pull request Nov 14, 2023
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 flatpak#5355.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit a058d96)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants