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>
This commit is contained in:
Philip Withnall 2018-09-05 11:25:03 +01:00
parent fd2d94dca5
commit dfa2a4ae75

View File

@ -3343,7 +3343,8 @@ g_test_trap_assertions (const char *domain,
logged_child_output = logged_child_output || log_child_output (process_id); 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_assertion_message (domain, file, line, func, msg);
g_free (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); 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_assertion_message (domain, file, line, func, msg);
g_free (msg); g_free (msg);
} }