test/harness/testcase.c
changeset 101 f44c530f80da
parent 96 8c2d6a0cf717
child 102 ff0aa9b1397a
     1.1 --- a/test/harness/testcase.c	Tue Sep 24 07:18:50 2013 +0100
     1.2 +++ b/test/harness/testcase.c	Sat Oct 26 18:47:33 2013 +0100
     1.3 @@ -326,6 +326,42 @@
     1.4  }
     1.5  
     1.6  /*
     1.7 + * Check the summary produced by bookloupe against testcase->summary.
     1.8 + */
     1.9 +static gboolean testcase_check_summary(Testcase *testcase,const char *summary)
    1.10 +{
    1.11 +    int i;
    1.12 +    gboolean r;
    1.13 +    gchar **lines;
    1.14 +    GSList *texts,*lnk;
    1.15 +    if (!testcase->summary.texts)
    1.16 +	return TRUE;
    1.17 +    texts=g_slist_copy(testcase->summary.texts);
    1.18 +    lines=g_strsplit(summary,"\n",0);
    1.19 +    for(i=0;lines[i];i++)
    1.20 +    {
    1.21 +	if (!g_str_has_prefix(lines[i],"   --> "))
    1.22 +	    continue;
    1.23 +	for(lnk=texts;lnk;lnk=lnk->next)
    1.24 +	    if (!strcmp(lines[i]+7,lnk->data))
    1.25 +	    {
    1.26 +		texts=g_slist_delete_link(texts,lnk);
    1.27 +		break;
    1.28 +	    }
    1.29 +    }
    1.30 +    g_strfreev(lines);
    1.31 +    r=!texts;
    1.32 +    if (texts)
    1.33 +    {
    1.34 +	g_print("%s: FAIL\n",testcase->basename);
    1.35 +	g_print("Missing summary text from bookloupe:\n");
    1.36 +	g_print("   --> %s\n",texts->data);
    1.37 +    }
    1.38 +    g_slist_free(texts);
    1.39 +    return r;
    1.40 +}
    1.41 +
    1.42 +/*
    1.43   * Check the warnings produced by bookloupe against either the
    1.44   * unstructured testcase->expected or the structured testcase->warnings
    1.45   * as appropriate.
    1.46 @@ -460,7 +496,7 @@
    1.47      gboolean r;
    1.48      size_t pos,offset;
    1.49      GString *header;
    1.50 -    char *output,*filename,*s,*xfail=NULL;
    1.51 +    char *output,*filename,*s,*summary,*xfail=NULL;
    1.52      GError *error=NULL;
    1.53      if (!testcase_create_input_files(testcase,&error))
    1.54      {
    1.55 @@ -500,10 +536,15 @@
    1.56      pos=header->len;
    1.57      if (r)
    1.58      {
    1.59 -	/* Skip the summary */
    1.60 +	/* Find the end of the summary */
    1.61  	s=strstr(output+pos,"\n\n");
    1.62  	if (s)
    1.63 +	{
    1.64 +	    summary=g_strndup(output+pos,s-(output+pos));
    1.65 +	    r=testcase_check_summary(testcase,summary);
    1.66 +	    g_free(summary);
    1.67  	    pos=s-output+2;
    1.68 +	}
    1.69  	else
    1.70  	{
    1.71  	    g_print("%s: FAIL\n",testcase->basename);
    1.72 @@ -512,7 +553,8 @@
    1.73  	}
    1.74      }
    1.75      g_string_free(header,TRUE);
    1.76 -    r=testcase_check_warnings(testcase,output+pos,&xfail);
    1.77 +    if (r)
    1.78 +	r=testcase_check_warnings(testcase,output+pos,&xfail);
    1.79      g_free(filename);
    1.80      g_free(output);
    1.81      if (r)