1.1 --- a/test/harness/testcase.c Sun Sep 29 22:51:27 2013 +0100
1.2 +++ b/test/harness/testcase.c Mon Oct 21 23:36:40 2013 +0100
1.3 @@ -384,6 +384,42 @@
1.4 return s-output+1;
1.5 }
1.6
1.7 + /*
1.8 + * Check the summary produced by bookloupe against testcase->summary.
1.9 + */
1.10 +static gboolean testcase_check_summary(Testcase *testcase,const char *summary)
1.11 +{
1.12 + int i;
1.13 + gboolean r;
1.14 + gchar **lines;
1.15 + GSList *texts,*lnk;
1.16 + if (!testcase->summary.texts)
1.17 + return TRUE;
1.18 + texts=g_slist_copy(testcase->summary.texts);
1.19 + lines=g_strsplit(summary,"\n",0);
1.20 + for(i=0;lines[i];i++)
1.21 + {
1.22 + if (!g_str_has_prefix(lines[i]," --> "))
1.23 + continue;
1.24 + for(lnk=texts;lnk;lnk=lnk->next)
1.25 + if (!strcmp(lines[i]+7,lnk->data))
1.26 + {
1.27 + texts=g_slist_delete_link(texts,lnk);
1.28 + break;
1.29 + }
1.30 + }
1.31 + g_strfreev(lines);
1.32 + r=!texts;
1.33 + if (texts)
1.34 + {
1.35 + g_print("%s: FAIL\n",testcase->basename);
1.36 + g_print("Missing summary text from bookloupe:\n");
1.37 + g_print(" --> %s\n",texts->data);
1.38 + }
1.39 + g_slist_free(texts);
1.40 + return r;
1.41 +}
1.42 +
1.43 /*
1.44 * Check the warnings produced by bookloupe against either the
1.45 * unstructured testcase->expected or the structured testcase->warnings
1.46 @@ -519,7 +555,7 @@
1.47 gboolean r;
1.48 size_t pos,offset;
1.49 GString *header;
1.50 - char *filename,*s,*xfail=NULL;
1.51 + char *filename,*s,*hdr,*summary,*xfail=NULL;
1.52 GError *error=NULL;
1.53 if (!testcase_create_input_files(testcase,&error))
1.54 {
1.55 @@ -558,23 +594,30 @@
1.56 print_unexpected(testcase->test_output,offset);
1.57 r=FALSE;
1.58 }
1.59 + summary=testcase->test_output+header->len;
1.60 pos=header->len;
1.61 if (r)
1.62 {
1.63 - /* Skip the summary */
1.64 - s=strstr(testcase->test_output+pos,"\n\n");
1.65 + /* Find the end of the summary */
1.66 + s=strstr(summary,"\n\n");
1.67 if (s)
1.68 + {
1.69 + summary=g_strndup(summary,s-summary);
1.70 + r=testcase_check_summary(testcase,summary);
1.71 + g_free(summary);
1.72 pos=s-testcase->test_output+2;
1.73 + }
1.74 else
1.75 {
1.76 g_print("%s: FAIL\n",testcase->basename);
1.77 - g_print("Unterminated summary from bookloupe:\n%s\n",
1.78 - testcase->test_output+pos);
1.79 + g_print("Unterminated summary from bookloupe:\n%s\n",summary);
1.80 r=FALSE;
1.81 }
1.82 }
1.83 g_string_free(header,TRUE);
1.84 - r=testcase_check_warnings(testcase,testcase->test_output+pos,&xfail);
1.85 + if (r)
1.86 + r=testcase_check_warnings(testcase,testcase->test_output+pos,
1.87 + &xfail);
1.88 }
1.89 if (!testcase_verify_output_files(testcase))
1.90 r=FALSE;