test-paint: Be more flexible for expected results

When generating the expected output with GENERATE_DATA=1,
Glib's test framework puts out some comments at the top
of the file. Ignore them when comparing the expected
output. This makes it possible to directly use the output
of

GENERATE_DATA=1 ./test-paint -p TESTCASE

as expected result for TESTCASE.
This commit is contained in:
Matthias Clasen 2023-01-08 09:01:31 -05:00
parent 5bd6fc1ace
commit f3ce137420
1 changed files with 16 additions and 0 deletions

View File

@ -394,6 +394,22 @@ test_hb_paint (gconstpointer d,
else
expected = g_strsplit (buffer, "\n", 0);
/* Strip initial comments */
int i;
for (i = 0; expected[i]; i++)
{
if (expected[i][0] != '#')
{
if (i > 0)
{
char **tmp = g_strdupv (expected + i);
g_strfreev (expected);
expected = tmp;
}
break;
}
}
if (g_strv_length (lines) != g_strv_length (expected))
{
g_test_message ("Unexpected number of lines in output (%d instead of %d)", g_strv_length (lines), g_strv_length (expected));