Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: MODIFIED: c-unit ...

autounit
Discussion topic

Back to topic list

CVS update: MODIFIED: c-unit ...

Reply

Author sjanes71
Full name Simon Janes
Date 2002-04-26 08:49:53 PDT
Message User: sjanes71
  Date: 02/04/26 08:49:53

  Modified: autounit/c-unit autounit.h suite.c test.c
  Log:
  Ooh, colors. TODO: terse/verbose and plain/color configurability, and
  HTML reports.
  
  Revision Changes Path
  1.3 +8 -0 autounit/autounit/c-​unit/autounit.h
  
  http://autounit.tigr​is.org/source/browse​/autounit/autounit/c​-unit/autounit.h.dif​f?r1=1.2&r2=1.3
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: autounit.h
  ====================​====================​====================​=======
  RCS file: /usr/local/tigris/da​ta/helm/cvs/reposito​ry/autounit/autounit​/c-unit/autounit.h,v​
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- autounit.h 2002/04/26 15:00:59 1.2
  +++ autounit.h 2002/04/26 15:49:52 1.3
  @@ -24,6 +24,9 @@
   #include <glib.h>
   
   /* #define AUTOUNIT_TEST_FAIL_MARKER "!" */
  +#define AUTOUNIT_ANSI_GREEN ("\033[01;32m")
  +#define AUTOUNIT_ANSI_RED ("\033[01;31m")
  +#define AUTOUNIT_ANSI_NORM ("\033[0m")
   #define AUTOUNIT_TEST_PASS_MARKER "."
   #define AUTOUNIT_TEST_FAIL_MARKER "F"
   
  @@ -34,6 +37,8 @@
   typedef gint (*autounit_test_tear​down_fp_t)(struct autounit_test_t_struct *t);
   typedef gint (*autounit_test_set_​status_fp)(struct autounit_test_t_struct *t,
                           char *msg);
  +
  +
   /**
    * A function of this type should return
    * 0 for equal
  @@ -58,6 +63,7 @@
     GSList *tests;
   };
   typedef struct autounit_suite_t_struct autounit_suite_t;
  +typedef void (*autounit_suite_rep​ort_fp_t)(autounit_s​uite_t *s);
   
   struct autounit_test_t_struct {
     autounit_suite_t *suite;
  @@ -89,6 +95,8 @@
   struct autounit_stress_report_t_struct {
     gint *round;
     gint modulo;
  + gboolean ansi_color;
  + gboolean verbose;
   };
   typedef struct autounit_stress_report_t_struct autounit_stress_report_t;
   
  
  
  
  1.2 +1 -0 autounit/autounit/c-​unit/suite.c
  
  http://autounit.tigr​is.org/source/browse​/autounit/autounit/c​-unit/suite.c.diff?r​1=1.1&r2=1.2
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: suite.c
  ====================​====================​====================​=======
  RCS file: /usr/local/tigris/da​ta/helm/cvs/reposito​ry/autounit/autounit​/c-unit/suite.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- suite.c 2002/04/25 13:48:05 1.1
  +++ suite.c 2002/04/26 15:49:52 1.2
  @@ -259,6 +259,7 @@
     au_log_start("au_run​_stress_suite");
     stress_report.round = &i;
     stress_report.modulo = status_modulo;
  + stress_report.verbose = FALSE;
   
     g_print(_("%s (%d iterations)\n"),tc-​>suite_name->s​tr,iterations);
     au_suite_reset_totals(tc);
  
  
  
  1.3 +63 -8 autounit/autounit/c-unit/test.c
  
  http://autounit.tigr​is.org/source/browse​/autounit/autounit/c​-unit/test.c.diff?r1​=1.2&r2=1.3
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: test.c
  ====================​====================​====================​=======
  RCS file: /usr/local/tigris/da​ta/helm/cvs/reposito​ry/autounit/autounit​/c-unit/test.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- test.c 2002/04/26 15:00:59 1.2
  +++ test.c 2002/04/26 15:49:52 1.3
  @@ -282,6 +282,62 @@
     g_timer_destroy(elapsed_timer);
   }
   
  +static void
  +terse_passfail_repo​rt(autounit_test_t *t,autounit_stress_report_t *status) {
  + gboolean ansi_color;
  + ansi_color = TRUE;
  + if (t->failed_assertions > 0) {
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_ANSI_RED));
  + }
  + g_print(_(AUTOUNIT_T​EST_FAIL_MARKER));
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_ANSI_NORM));
  + }
  + } else {
  + if ((*(status->round) % status->modulo) == 0) {
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_A​NSI_GREEN));
  + }
  + g_print(_(AUTOUNIT_T​EST_PASS_MARKER));
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_ANSI_NORM));
  + }
  + }
  + }
  +}
  +
  +static void
  +verbose_passfail_re​port(autounit_test_t​ *t,autounit_stress_report_t *status) {
  + gboolean ansi_color;
  + ansi_color = TRUE;
  + if (t->failed_assertions > 0) {
  + g_print(" [ ");
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_ANSI_RED));
  + }
  + g_print(_("FAILED"));
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_ANSI_NORM));
  + }
  + g_print(" %s\n%s ]\n",t->test_nam​e->str,t->test​_status->str);
  +
  + } else {
  + if ((*(status->round) % status->modulo) == 0) {
  + g_print(" [ ");
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_A​NSI_GREEN));
  + }
  + g_print(_("PASSED"));
  + if (ansi_color) {
  + g_print(_(AUTOUNIT_ANSI_NORM));
  + }
  + g_print(" %s %s ]\n",t->test_nam​e->str,t->test​_status->str);
  + }
  + }
  +}
  +
  +
   void
   au_run_test_fork(aut​ounit_test_t *t,
            autounit_stress_report_t *status)
  @@ -362,13 +418,12 @@
       au_run_test_child(t);
     }
     
  - if (t->failed_assertions > 0) {
  - g_print(_(AUTOUNIT_T​EST_FAIL_MARKER));
  - } else {
  - if ((*(status->round) % status->modulo) == 0) {
  - g_print(_(AUTOUNIT_T​EST_PASS_MARKER));
  - }
  - }
  + if (status->verbose)
  + verbose_passfail_rep​ort(t,status);
  + else
  + terse_passfail_repor​t(t,status);
  +
   }
  +
   
   
  
  
  

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@auto​unit.tigris.org
For additional commands, e-mail: cvs-help at autounit dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: MODIFIED: c-unit ... sjanes71 Simon Janes 2002-04-26 08:49:53 PDT
Messages per page: