test/harness/testcase.c
changeset 200 8e0ba1a088c4
parent 167 f0740133c606
parent 184 cd3068704d3a
     1.1 --- a/test/harness/testcase.c	Sun Sep 29 22:51:27 2013 +0100
     1.2 +++ b/test/harness/testcase.c	Sun Oct 27 16:36:46 2013 +0000
     1.3 @@ -385,6 +385,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 @@ -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,*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;