tests: Fix a minor leak in a new GSubprocess test

And also rearrange the asserts so that the error is checked first (since
that’s the more informative failure to receive if the test did fail).

Spotted by Marco in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4494#note_2352013
and by The Machines in
https://gitlab.gnome.org/GNOME/glib/-/jobs/4768121.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall
2025-02-18 15:04:06 +00:00
parent e46d54074b
commit 9d81da62f2

View File

@@ -1356,16 +1356,16 @@ static void
test_fail_initialization (void)
{
GError *local_error = NULL;
GError **error = &local_error;
GSubprocess *proc;
proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE,
error,
&local_error,
"thisprogramshouldnotexistprettyplease",
NULL);
g_assert_null (proc);
g_assert_error (local_error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT);
g_assert_null (proc);
g_clear_error (&local_error);
}
#ifdef G_OS_UNIX