Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 0bb83b54a -> b2da42dcc


Improve skipping of tests

- Allow to skip multiple tests at once
- Correct TAP output for skipped tests


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/b2da42dc
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/b2da42dc
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/b2da42dc

Branch: refs/heads/master
Commit: b2da42dccebc677d45c2f0167a671d12abb27069
Parents: 0bb83b5
Author: Nick Wellnhofer <[email protected]>
Authored: Sat Dec 27 14:59:23 2014 +0100
Committer: Nick Wellnhofer <[email protected]>
Committed: Sat Dec 27 14:59:23 2014 +0100

----------------------------------------------------------------------
 .../Clownfish/TestHarness/TestBatchRunner.c     | 18 +++++++--------
 .../Clownfish/TestHarness/TestBatchRunner.cfh   |  5 +++--
 .../core/Clownfish/TestHarness/TestFormatter.c  | 23 ++++++++++++++++++++
 .../Clownfish/TestHarness/TestFormatter.cfh     | 19 ++++++++++++++++
 4 files changed, 54 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b2da42dc/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/TestHarness/TestBatchRunner.c 
b/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
index a237df9..aacffa4 100644
--- a/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
+++ b/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
@@ -200,10 +200,11 @@ TestBatchRunner_fail(TestBatchRunner *self, const char 
*pattern, ...) {
 }
 
 void
-TestBatchRunner_skip(TestBatchRunner *self, const char *pattern, ...) {
+TestBatchRunner_skip(TestBatchRunner *self, uint32_t num, const char *pattern,
+                     ...) {
     va_list args;
     va_start(args, pattern);
-    TestBatchRunner_VSkip(self, pattern, args);
+    TestBatchRunner_VSkip(self, num, pattern, args);
     va_end(args);
 }
 
@@ -275,13 +276,12 @@ TestBatchRunner_VFail_IMP(TestBatchRunner *self, const 
char *pattern,
 }
 
 void
-TestBatchRunner_VSkip_IMP(TestBatchRunner *self, const char *pattern,
-                          va_list args) {
-    self->test_num++;
-    // TODO: Add a VTest_Skip method to TestFormatter
-    TestFormatter_VTest_Result(self->formatter, true, self->test_num,
-                               pattern, args);
-    self->num_skipped++;
+TestBatchRunner_VSkip_IMP(TestBatchRunner *self, uint32_t num,
+                          const char *pattern, va_list args) {
+    self->test_num += num;
+    TestFormatter_VTest_Skip(self->formatter, self->test_num, num, pattern,
+                             args);
+    self->num_skipped += num;
 }
 
 static bool

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b2da42dc/runtime/core/Clownfish/TestHarness/TestBatchRunner.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/TestHarness/TestBatchRunner.cfh 
b/runtime/core/Clownfish/TestHarness/TestBatchRunner.cfh
index cde51f7..20a4ab1 100644
--- a/runtime/core/Clownfish/TestHarness/TestBatchRunner.cfh
+++ b/runtime/core/Clownfish/TestHarness/TestBatchRunner.cfh
@@ -86,7 +86,7 @@ class Clownfish::TestHarness::TestBatchRunner inherits 
Clownfish::Obj {
     fail(TestBatchRunner *self, const char *pattern, ...);
 
     inert void
-    skip(TestBatchRunner *self, const char *pattern, ...);
+    skip(TestBatchRunner *self, uint32_t num, const char *pattern, ...);
 
     bool
     VTest_True(TestBatchRunner *self, bool condition, const char *pattern,
@@ -116,7 +116,8 @@ class Clownfish::TestHarness::TestBatchRunner inherits 
Clownfish::Obj {
     VFail(TestBatchRunner *self, const char *pattern, va_list args);
 
     void
-    VSkip(TestBatchRunner *self, const char *pattern, va_list args);
+    VSkip(TestBatchRunner *self, uint32_t num, const char *pattern,
+          va_list args);
 }
 
 __C__

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b2da42dc/runtime/core/Clownfish/TestHarness/TestFormatter.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/TestHarness/TestFormatter.c 
b/runtime/core/Clownfish/TestHarness/TestFormatter.c
index e8c3d33..797ae84 100644
--- a/runtime/core/Clownfish/TestHarness/TestFormatter.c
+++ b/runtime/core/Clownfish/TestHarness/TestFormatter.c
@@ -95,6 +95,17 @@ TestFormatterCF_VTest_Result_IMP(TestFormatterCF *self, bool 
pass,
 }
 
 void
+TestFormatterCF_VTest_Skip_IMP(TestFormatterCF *self, uint32_t test_num,
+                               uint32_t num_skipped, const char *fmt,
+                               va_list args) {
+    UNUSED_VAR(self);
+    UNUSED_VAR(test_num);
+    UNUSED_VAR(num_skipped);
+    UNUSED_VAR(fmt);
+    UNUSED_VAR(args);
+}
+
+void
 TestFormatterCF_VTest_Comment_IMP(TestFormatterCF *self, const char *fmt,
                                   va_list args) {
     UNUSED_VAR(self);
@@ -166,6 +177,18 @@ TestFormatterTAP_VTest_Result_IMP(TestFormatterTAP *self, 
bool pass,
 }
 
 void
+TestFormatterTAP_VTest_Skip_IMP(TestFormatterTAP *self, uint32_t test_num,
+                                uint32_t num_skipped, const char *fmt,
+                                va_list args) {
+    UNUSED_VAR(self);
+    for (uint32_t i = 0; i < num_skipped; ++i) {
+        printf("ok %u # SKIP ", test_num + i);
+        vprintf(fmt, args);
+        printf("\n");
+    }
+}
+
+void
 TestFormatterTAP_VTest_Comment_IMP(TestFormatterTAP *self, const char *fmt,
                                    va_list args) {
     UNUSED_VAR(self);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b2da42dc/runtime/core/Clownfish/TestHarness/TestFormatter.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/TestHarness/TestFormatter.cfh 
b/runtime/core/Clownfish/TestHarness/TestFormatter.cfh
index 92ca911..f39a35b 100644
--- a/runtime/core/Clownfish/TestHarness/TestFormatter.cfh
+++ b/runtime/core/Clownfish/TestHarness/TestFormatter.cfh
@@ -51,6 +51,17 @@ abstract class Clownfish::TestHarness::TestFormatter 
inherits Clownfish::Obj {
     VTest_Result(TestFormatter *self, bool pass, uint32_t test_num,
                  const char *fmt, va_list args);
 
+    /** Print diagnostics for skipped tests.
+     *
+     * @param test_num The sequence number of the first skipped test.
+     * @param num_skipped The number of skipped tests.
+     * @param fmt printf-style format string.
+     * @param args Additional arguments.
+     */
+    abstract void
+    VTest_Skip(TestFormatter *self, uint32_t test_num, uint32_t num_skipped,
+               const char *fmt, va_list args);
+
     /** Print additional diagnosis for a test.
      *
      * @param fmt printf-style format string.
@@ -98,6 +109,10 @@ class Clownfish::Test::Formatter::TestFormatterCF
                  const char *fmt, va_list args);
 
     void
+    VTest_Skip(TestFormatterCF *self, uint32_t test_num, uint32_t num_skipped,
+               const char *fmt, va_list args);
+
+    void
     VTest_Comment(TestFormatterCF *self, const char *fmt, va_list args);
 
     void
@@ -130,6 +145,10 @@ class Clownfish::Test::Formatter::TestFormatterTAP
                  const char *fmt, va_list args);
 
     void
+    VTest_Skip(TestFormatterTAP *self, uint32_t test_num, uint32_t num_skipped,
+               const char *fmt, va_list args);
+
+    void
     VTest_Comment(TestFormatterTAP *self, const char *fmt, va_list args);
 
     void

Reply via email to