[glib: 1/5] gtestutils: Print non-matching stderr/stdout output on trap failure



commit dfa2a4ae75af50d6dfa66cdfb14efb382140d22a
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Sep 5 11:25:03 2018 +0100

    gtestutils: Print non-matching stderr/stdout output on trap failure
    
    When running a test as a subprocess and matching its output, it’s very
    annoying for GLib to tell you that the output didn’t match your pattern,
    *but not actually say what the output was*. Fix that.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 glib/gtestutils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 7b29c274e..119c55d92 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -3343,7 +3343,8 @@ g_test_trap_assertions (const char     *domain,
 
       logged_child_output = logged_child_output || log_child_output (process_id);
 
-      msg = g_strdup_printf ("stdout of child process (%s) %s: %s", process_id, match_error, stdout_pattern);
+      msg = g_strdup_printf ("stdout of child process (%s) %s: %s\nstderr was:\n%s",
+                             process_id, match_error, stdout_pattern, test_trap_last_stdout);
       g_assertion_message (domain, file, line, func, msg);
       g_free (msg);
     }
@@ -3353,7 +3354,8 @@ g_test_trap_assertions (const char     *domain,
 
       logged_child_output = logged_child_output || log_child_output (process_id);
 
-      msg = g_strdup_printf ("stderr of child process (%s) %s: %s", process_id, match_error, stderr_pattern);
+      msg = g_strdup_printf ("stderr of child process (%s) %s: %s\nstderr was:\n%s",
+                             process_id, match_error, stderr_pattern, test_trap_last_stderr);
       g_assertion_message (domain, file, line, func, msg);
       g_free (msg);
     }


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