From c3de8bca2d084e90a77d50db40447f145520e4f5 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 8 Jun 2020 17:52:56 +0100 Subject: tests: Ensure we respect the TAP output format When dumping the diff between the computed and expected results, we need to respect the TAP format and place "#" in front of each line. --- tests/test-break.c | 15 ++++++++++++--- tests/test-itemize.c | 15 ++++++++++++--- tests/test-layout.c | 14 +++++++++++--- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/tests/test-break.c b/tests/test-break.c index e92cbe8e..cdb7e6c0 100644 --- a/tests/test-break.c +++ b/tests/test-break.c @@ -260,18 +260,27 @@ test_break (gconstpointer d) diff = diff_with_file (expected_file, dump->str, dump->len, &error); g_assert_no_error (error); + setlocale (LC_ALL, old_locale); + if (diff && diff[0]) { + char **lines = g_strsplit (diff, "\n", -1); + const char *line; + int i = 0; + g_test_message ("Contents don't match expected contents"); - g_test_message ("%s", diff); + + for (line = lines[0]; line != NULL; line = lines[++i]) + g_test_message ("%s", line); + g_test_fail (); + + g_strfreev (lines); g_free (diff); } g_string_free (dump, TRUE); g_free (expected_file); - - setlocale (LC_ALL, old_locale); } int diff --git a/tests/test-itemize.c b/tests/test-itemize.c index 51f2bb9c..1709b834 100644 --- a/tests/test-itemize.c +++ b/tests/test-itemize.c @@ -256,18 +256,27 @@ test_itemize (gconstpointer d) diff = diff_with_file (expected_file, dump->str, dump->len, &error); g_assert_no_error (error); + setlocale (LC_ALL, old_locale); + if (diff && diff[0]) { + char **lines = g_strsplit (diff, "\n", -1); + const char *line; + int i = 0; + g_test_message ("Contents don't match expected contents"); - g_test_message ("%s", diff); + + for (line = lines[0]; line != NULL; line = lines[++i]) + g_test_message ("%s", line); + g_test_fail (); + + g_strfreev (lines); g_free (diff); } g_string_free (dump, TRUE); g_free (expected_file); - - setlocale (LC_ALL, old_locale); } int diff --git a/tests/test-layout.c b/tests/test-layout.c index 9661457b..623b7a70 100644 --- a/tests/test-layout.c +++ b/tests/test-layout.c @@ -323,18 +323,26 @@ test_layout (gconstpointer d) diff = diff_with_file (expected_file, dump->str, dump->len, &error); g_assert_no_error (error); + setlocale (LC_ALL, old_locale); + if (diff && diff[0]) { + char **lines = g_strsplit (diff, "\n", -1); + const char *line; + int i = 0; + g_test_message ("Contents don't match expected contents"); - g_test_message ("%s", diff); + + for (line = lines[0]; line != NULL; line = lines[++i]) + g_test_message ("%s", line); + g_test_fail (); + g_strfreev (lines); g_free (diff); } g_string_free (dump, TRUE); g_free (expected_file); - - setlocale (LC_ALL, old_locale); } int -- cgit v1.2.1