[Expat-checkins] expat/tests minicheck.c, 1.2, 1.3 minicheck.h, 1.3, 1.4

Fred L. Drake fdrake at users.sourceforge.net
Fri Jan 28 07:32:34 CET 2005


Update of /cvsroot/expat/expat/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16864/tests

Modified Files:
	minicheck.c minicheck.h 
Log Message:
implement verbose mode in minicheck to make it easier to determine which
tests failed


Index: minicheck.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/minicheck.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- minicheck.c	15 Jul 2004 22:54:18 -0000	1.2
+++ minicheck.c	28 Jan 2005 06:32:30 -0000	1.3
@@ -90,6 +90,29 @@
 
 static jmp_buf env;
 
+static char const *_check_current_function = NULL;
+static int _check_current_lineno = -1;
+static char const *_check_current_filename = NULL;
+
+void
+_check_set_test_info(char const *function, char const *filename, int lineno)
+{
+    _check_current_function = function;
+    _check_current_lineno = lineno;
+    _check_current_filename = filename;
+}
+
+
+static void
+add_failure(SRunner *runner, int verbosity)
+{
+    runner->nfailures++;
+    if (verbosity >= CK_VERBOSE) {
+        printf("%s:%s:%d\n", _check_current_function,
+               _check_current_filename, _check_current_lineno);
+    }
+}
+
 void
 srunner_run_all(SRunner *runner, int verbosity)
 {
@@ -106,14 +129,14 @@
             if (tc->setup != NULL) {
                 /* setup */
                 if (setjmp(env)) {
-                    runner->nfailures++;
+                    add_failure(runner, verbosity);
                     continue;
                 }
                 tc->setup();
             }
             /* test */
             if (setjmp(env)) {
-                runner->nfailures++;
+                add_failure(runner, verbosity);
                 continue;
             }
             (tc->tests[i])();
@@ -121,7 +144,7 @@
             /* teardown */
             if (tc->teardown != NULL) {
                 if (setjmp(env)) {
-                    runner->nfailures++;
+                    add_failure(runner, verbosity);
                     continue;
                 }
                 tc->teardown();

Index: minicheck.h
===================================================================
RCS file: /cvsroot/expat/expat/tests/minicheck.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- minicheck.h	30 Sep 2004 04:58:09 -0000	1.3
+++ minicheck.h	28 Jan 2005 06:32:31 -0000	1.4
@@ -18,8 +18,10 @@
 #define CK_NORMAL  1
 #define CK_VERBOSE 2
 
-#define START_TEST(testname) static void testname(void) {
-#define END_TEST }
+#define START_TEST(testname) static void testname(void) { \
+    _check_set_test_info(__func__, __FILE__, __LINE__);   \
+    {
+#define END_TEST } }
 
 #define fail(msg)  _fail_unless(0, __FILE__, __LINE__, msg)
 
@@ -54,6 +56,11 @@
 };
 
 
+/* Internal helper. */
+void _check_set_test_info(char const *function,
+                          char const *filename, int lineno);
+
+
 /*
  * Prototypes for the actual implementation.
  */



More information about the Expat-checkins mailing list