@@ -139,6 +139,7 @@ static struct {
139139 int exit_on_error ;
140140 int report_suite_names ;
141141 int write_summary ;
142+ const char * summary_file ;
142143
143144 struct clar_explicit * explicit ;
144145 struct clar_explicit * last_explicit ;
@@ -183,6 +184,10 @@ static void clar_print_onabort(const char *msg, ...);
183184static void clar_unsandbox (void );
184185static int clar_sandbox (void );
185186
187+ /* From summary.h */
188+ static int clar_summary_init (const char * filename );
189+ static void clar_summary_shutdown (void );
190+
186191/* Load the declarations for the test suite */
187192#include "clar.suite"
188193
@@ -466,6 +471,8 @@ clar_parse_args(int argc, char **argv)
466471
467472 case 'r' :
468473 _clar .write_summary = 1 ;
474+ _clar .summary_file = * (argument + 2 ) ? (argument + 2 ) :
475+ "summary.xml" ;
469476 break ;
470477
471478 default :
@@ -486,6 +493,11 @@ clar_test_init(int argc, char **argv)
486493 if (argc > 1 )
487494 clar_parse_args (argc , argv );
488495
496+ if (_clar .write_summary && !clar_summary_init (_clar .summary_file )) {
497+ clar_print_onabort ("Failed to open the summary file: %s\n" );
498+ exit (-1 );
499+ }
500+
489501 if (clar_sandbox () < 0 ) {
490502 clar_print_onabort ("Failed to sandbox the test runner.\n" );
491503 exit (-1 );
@@ -509,8 +521,6 @@ clar_test_run(void)
509521 return _clar .total_errors ;
510522}
511523
512- static void clar_summary_write (void );
513-
514524void
515525clar_test_shutdown (void )
516526{
@@ -526,7 +536,7 @@ clar_test_shutdown(void)
526536 clar_unsandbox ();
527537
528538 if (_clar .write_summary )
529- clar_summary_write ();
539+ clar_summary_shutdown ();
530540
531541 for (explicit = _clar .explicit ; explicit ; explicit = explicit_next ) {
532542 explicit_next = explicit -> next ;
0 commit comments