1+ /* clap: clar protocol, the traditional clar output format */
12
2- static void clar_print_cl_init (int test_count , int suite_count , const char * suite_names )
3+ static void clar_print_clap_init (int test_count , int suite_count , const char * suite_names )
34{
45 (void )test_count ;
56 printf ("Loaded %d suites: %s\n" , (int )suite_count , suite_names );
67 printf ("Started (test status codes: OK='.' FAILURE='F' SKIPPED='S')\n" );
78}
89
9- static void clar_print_cl_shutdown (int test_count , int suite_count , int error_count )
10+ static void clar_print_clap_shutdown (int test_count , int suite_count , int error_count )
1011{
1112 (void )test_count ;
1213 (void )suite_count ;
@@ -16,7 +17,7 @@ static void clar_print_cl_shutdown(int test_count, int suite_count, int error_co
1617 clar_report_all ();
1718}
1819
19- static void clar_print_cl_error (int num , const struct clar_report * report , const struct clar_error * error )
20+ static void clar_print_clap_error (int num , const struct clar_report * report , const struct clar_error * error )
2021{
2122 printf (" %d) Failure:\n" , num );
2223
@@ -35,7 +36,7 @@ static void clar_print_cl_error(int num, const struct clar_report *report, const
3536 fflush (stdout );
3637}
3738
38- static void clar_print_cl_ontest (const char * test_name , int test_number , enum cl_test_status status )
39+ static void clar_print_clap_ontest (const char * test_name , int test_number , enum cl_test_status status )
3940{
4041 (void )test_name ;
4142 (void )test_number ;
@@ -50,48 +51,60 @@ static void clar_print_cl_ontest(const char *test_name, int test_number, enum cl
5051 fflush (stdout );
5152}
5253
53- static void clar_print_cl_onsuite (const char * suite_name , int suite_index )
54+ static void clar_print_clap_onsuite (const char * suite_name , int suite_index )
5455{
5556 if (_clar .report_suite_names )
5657 printf ("\n%s" , suite_name );
5758
5859 (void )suite_index ;
5960}
6061
61- static void clar_print_cl_onabort (const char * fmt , va_list arg )
62+ static void clar_print_clap_onabort (const char * fmt , va_list arg )
6263{
6364 vfprintf (stderr , fmt , arg );
6465}
6566
67+ /* indirection between protocol output selection */
68+
69+ #define PRINT (FN , args ...) do { \
70+ switch (_clar.output_format) { \
71+ case CL_OUTPUT_CLAP: \
72+ clar_print_clap_##FN (args); \
73+ break; \
74+ default: \
75+ abort(); \
76+ } \
77+ } while (0)
78+
6679static void clar_print_init (int test_count , int suite_count , const char * suite_names )
6780{
68- clar_print_cl_init ( test_count , suite_count , suite_names );
81+ PRINT ( init , test_count , suite_count , suite_names );
6982}
7083
7184static void clar_print_shutdown (int test_count , int suite_count , int error_count )
7285{
73- clar_print_cl_shutdown ( test_count , suite_count , error_count );
86+ PRINT ( shutdown , test_count , suite_count , error_count );
7487}
7588
7689static void clar_print_error (int num , const struct clar_report * report , const struct clar_error * error )
7790{
78- clar_print_cl_error ( num , report , error );
91+ PRINT ( error , num , report , error );
7992}
8093
8194static void clar_print_ontest (const char * test_name , int test_number , enum cl_test_status status )
8295{
83- clar_print_cl_ontest ( test_name , test_number , status );
96+ PRINT ( ontest , test_name , test_number , status );
8497}
8598
8699static void clar_print_onsuite (const char * suite_name , int suite_index )
87100{
88- clar_print_cl_onsuite ( suite_name , suite_index );
101+ PRINT ( onsuite , suite_name , suite_index );
89102}
90103
91104static void clar_print_onabort (const char * msg , ...)
92105{
93106 va_list argp ;
94107 va_start (argp , msg );
95- clar_print_cl_onabort ( msg , argp );
108+ PRINT ( onabort , msg , argp );
96109 va_end (argp );
97110}
0 commit comments