[glib/wip/who-tests-the-tests-themselves] tests: Fix error handling when testing gtestutils




commit b006403c4e3e10dc136476809463cc26fb17e19a
Author: Simon McVittie <smcv collabora com>
Date:   Thu Aug 5 12:07:15 2021 +0100

    tests: Fix error handling when testing gtestutils
    
    We had two compensating bugs here. We didn't correctly clear the
    error indicator after testing a test-case that calls g_test_fail(),
    which meant we were leaving the error set to exit status 1 when
    falling through to the next test; and then we didn't check the exit
    status of the next test, but instead assumed that g_spawn_sync()
    would fail (it does not).
    
    Signed-off-by: Simon McVittie <smcv collabora com>

 glib/tests/testing.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index 81b8f5405..fd10f4891 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -1136,6 +1136,7 @@ test_tap (void)
   g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
   g_assert_nonnull (strstr (output, "\nnot ok 1 /fail\n"));
   g_free (output);
+  g_clear_error (&error);
   g_ptr_array_unref (argv);
 
   g_test_message ("all");
@@ -1149,6 +1150,9 @@ test_tap (void)
                 G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
                 NULL, NULL, NULL, NULL, &status,
                 &error);
+  g_assert_no_error (error);
+
+  g_spawn_check_wait_status (status, &error);
   g_assert_error (error, G_SPAWN_EXIT_ERROR, 1);
   g_clear_error (&error);
   g_ptr_array_unref (argv);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]