You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/02/17 16:00:45 UTC

[lucy-commits] [3/3] git commit: refs/heads/clownfish-test-v2 - Consolidate test formatter code into a single file

Updated Branches:
  refs/heads/clownfish-test-v2 49cf506ad -> 4857ea762


Consolidate test formatter code into a single file


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

Branch: refs/heads/clownfish-test-v2
Commit: 4857ea762f10960faa8b9714c5d4053888388c9b
Parents: e92327c
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 17 15:48:47 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Feb 17 15:48:47 2013 +0100

----------------------------------------------------------------------
 core/Clownfish/Test/Formatter/TestFormatterCF.c    |   99 -----------
 core/Clownfish/Test/Formatter/TestFormatterCF.cfh  |   49 ------
 core/Clownfish/Test/Formatter/TestFormatterTAP.c   |   79 ---------
 core/Clownfish/Test/Formatter/TestFormatterTAP.cfh |   49 ------
 core/Clownfish/Test/TestFormatter.c                |  128 +++++++++++++++
 core/Clownfish/Test/TestFormatter.cfh              |   60 +++++++
 core/Lucy/Test.c                                   |    1 -
 7 files changed, 188 insertions(+), 277 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Clownfish/Test/Formatter/TestFormatterCF.c
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/Formatter/TestFormatterCF.c b/core/Clownfish/Test/Formatter/TestFormatterCF.c
deleted file mode 100644
index 93ceb14..0000000
--- a/core/Clownfish/Test/Formatter/TestFormatterCF.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-
-#define C_LUCY_TESTFORMATTERCF
-#define LUCY_USE_SHORT_NAMES
-#define CHY_USE_SHORT_NAMES
-
-#include "Clownfish/Test/Formatter/TestFormatterCF.h"
-#include "Clownfish/CharBuf.h"
-#include "Lucy/Test.h"
-#include "Clownfish/Test/TestRunner.h"
-#include "Clownfish/VTable.h"
-
-TestFormatterCF*
-TestFormatterCF_new() {
-    TestFormatterCF *self
-        = (TestFormatterCF*)VTable_Make_Obj(TESTFORMATTERCF);
-    return TestFormatterCF_init(self);
-}
-
-TestFormatterCF*
-TestFormatterCF_init(TestFormatterCF *self) {
-    return (TestFormatterCF*)TestFormatter_init((TestFormatter*)self);
-}
-
-void
-TestFormatterCF_batch_prologue(TestFormatterCF *self, TestBatch *batch) {
-    UNUSED_VAR(self);
-    CharBuf *class_name = TestBatch_Get_Class_Name(batch);
-    printf("Testing %s...\n", CB_Get_Ptr8(class_name));
-}
-
-void
-TestFormatterCF_vtest_result(TestFormatterCF *self, bool pass,
-                             uint32_t test_num, const char *fmt,
-                             va_list args) {
-    UNUSED_VAR(self);
-    if (!pass) {
-        printf("  Failed test %u: ", test_num);
-        vprintf(fmt, args);
-        printf("\n");
-    }
-}
-
-void
-TestFormatterCF_vtest_comment(TestFormatterCF *self, const char *fmt,
-                              va_list args) {
-    UNUSED_VAR(self);
-    printf("    ");
-    vprintf(fmt, args);
-}
-
-void
-TestFormatterCF_vbatch_comment(TestFormatterCF *self, const char *fmt,
-                               va_list args) {
-    UNUSED_VAR(self);
-    printf("  ");
-    vprintf(fmt, args);
-}
-
-void
-TestFormatterCF_summary(TestFormatterCF *self, TestRunner *runner) {
-    UNUSED_VAR(self);
-    uint32_t num_batches        = TestRunner_Get_Num_Batches(runner);
-    uint32_t num_batches_failed = TestRunner_Get_Num_Batches_Failed(runner);
-    uint32_t num_tests          = TestRunner_Get_Num_Tests(runner);
-    uint32_t num_tests_failed   = TestRunner_Get_Num_Tests_Failed(runner);
-
-    if (num_batches == 0) {
-        printf("No tests planned or run.\n");
-    }
-    else if (num_batches_failed == 0) {
-        printf("%u batches passed. %u tests passed.\n", num_batches,
-               num_tests);
-        printf("Result: PASS\n");
-    }
-    else {
-        printf("%u/%u batches failed. %u/%u tests failed.\n",
-               num_batches_failed, num_batches, num_tests_failed, num_tests);
-        printf("Result: FAIL\n");
-    }
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Clownfish/Test/Formatter/TestFormatterCF.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/Formatter/TestFormatterCF.cfh b/core/Clownfish/Test/Formatter/TestFormatterCF.cfh
deleted file mode 100644
index ccf9267..0000000
--- a/core/Clownfish/Test/Formatter/TestFormatterCF.cfh
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-parcel Lucy;
-
-/**
- * A TestFormatter that produces human-readable output in a custom
- * "Clownfish" format.
- */
-class Clownfish::Test::Formatter::TestFormatterCF
-    inherits Clownfish::Test::TestFormatter {
-
-    inert incremented TestFormatterCF*
-    new();
-
-    inert TestFormatterCF*
-    init(TestFormatterCF *self);
-
-    void
-    Batch_Prologue(TestFormatterCF *self, TestBatch *batch);
-
-    void
-    VTest_Result(TestFormatterCF *self, bool pass, uint32_t test_num,
-                 const char *fmt, va_list args);
-
-    void
-    VTest_Comment(TestFormatterCF *self, const char *fmt, va_list args);
-
-    void
-    VBatch_Comment(TestFormatterCF *self, const char *fmt, va_list args);
-
-    void
-    Summary(TestFormatterCF *self, TestRunner *runner);
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Clownfish/Test/Formatter/TestFormatterTAP.c
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/Formatter/TestFormatterTAP.c b/core/Clownfish/Test/Formatter/TestFormatterTAP.c
deleted file mode 100644
index d67edb2..0000000
--- a/core/Clownfish/Test/Formatter/TestFormatterTAP.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-
-#define C_LUCY_TESTFORMATTERTAP
-#define LUCY_USE_SHORT_NAMES
-#define CHY_USE_SHORT_NAMES
-
-#include "Clownfish/Test/Formatter/TestFormatterTAP.h"
-#include "Lucy/Test.h"
-#include "Clownfish/Test/TestRunner.h"
-#include "Clownfish/VTable.h"
-
-TestFormatterTAP*
-TestFormatterTAP_new() {
-    TestFormatterTAP *self
-        = (TestFormatterTAP*)VTable_Make_Obj(TESTFORMATTERTAP);
-    return TestFormatterTAP_init(self);
-}
-
-TestFormatterTAP*
-TestFormatterTAP_init(TestFormatterTAP *self) {
-    return (TestFormatterTAP*)TestFormatter_init((TestFormatter*)self);
-}
-
-void
-TestFormatterTAP_batch_prologue(TestFormatterTAP *self, TestBatch *batch) {
-    UNUSED_VAR(self);
-    printf("1..%" PRId64 "\n", TestBatch_Get_Num_Planned(batch));
-}
-
-void
-TestFormatterTAP_vtest_result(TestFormatterTAP *self, bool pass,
-                              uint32_t test_num, const char *fmt,
-                              va_list args) {
-    UNUSED_VAR(self);
-    const char *result = pass ? "ok" : "not ok";
-    printf("%s %d - ", result, test_num);
-    vprintf(fmt, args);
-    printf("\n");
-}
-
-void
-TestFormatterTAP_vtest_comment(TestFormatterTAP *self, const char *fmt,
-                               va_list args) {
-    UNUSED_VAR(self);
-    printf("#   ");
-    vprintf(fmt, args);
-}
-
-void
-TestFormatterTAP_vbatch_comment(TestFormatterTAP *self, const char *fmt,
-                                va_list args) {
-    UNUSED_VAR(self);
-    printf("# ");
-    vprintf(fmt, args);
-}
-
-void
-TestFormatterTAP_summary(TestFormatterTAP *self, TestRunner *runner) {
-    UNUSED_VAR(self);
-    UNUSED_VAR(runner);
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh b/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh
deleted file mode 100644
index 969f9f6..0000000
--- a/core/Clownfish/Test/Formatter/TestFormatterTAP.cfh
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-parcel Lucy;
-
-/**
- * A TestFormatter that produces TAP output (Test Anything Protocol).
- * See http://testanything.org/
- */
-class Clownfish::Test::Formatter::TestFormatterTAP
-    inherits Clownfish::Test::TestFormatter {
-
-    inert incremented TestFormatterTAP*
-    new();
-
-    inert TestFormatterTAP*
-    init(TestFormatterTAP *self);
-
-    void
-    Batch_Prologue(TestFormatterTAP *self, TestBatch *batch);
-
-    void
-    VTest_Result(TestFormatterTAP *self, bool pass, uint32_t test_num,
-                 const char *fmt, va_list args);
-
-    void
-    VTest_Comment(TestFormatterTAP *self, const char *fmt, va_list args);
-
-    void
-    VBatch_Comment(TestFormatterTAP *self, const char *fmt, va_list args);
-
-    void
-    Summary(TestFormatterTAP *self, TestRunner *runner);
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Clownfish/Test/TestFormatter.c
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/TestFormatter.c b/core/Clownfish/Test/TestFormatter.c
index 207e675..b4aead0 100644
--- a/core/Clownfish/Test/TestFormatter.c
+++ b/core/Clownfish/Test/TestFormatter.c
@@ -14,11 +14,18 @@
  * limitations under the License.
  */
 
+#include <stdio.h>
+
 #define C_LUCY_TESTFORMATTER
 #define LUCY_USE_SHORT_NAMES
+#define CHY_USE_SHORT_NAMES
 
 #include "Clownfish/Test/TestFormatter.h"
+#include "Clownfish/CharBuf.h"
 #include "Clownfish/Err.h"
+#include "Lucy/Test.h"
+#include "Clownfish/Test/TestRunner.h"
+#include "Clownfish/VTable.h"
 
 TestFormatter*
 TestFormatter_init(TestFormatter *self) {
@@ -52,4 +59,125 @@ TestFormatter_batch_comment(void *vself, const char *fmt, ...) {
     va_end(args);
 }
 
+TestFormatterCF*
+TestFormatterCF_new() {
+    TestFormatterCF *self
+        = (TestFormatterCF*)VTable_Make_Obj(TESTFORMATTERCF);
+    return TestFormatterCF_init(self);
+}
+
+TestFormatterCF*
+TestFormatterCF_init(TestFormatterCF *self) {
+    return (TestFormatterCF*)TestFormatter_init((TestFormatter*)self);
+}
+
+void
+TestFormatterCF_batch_prologue(TestFormatterCF *self, TestBatch *batch) {
+    UNUSED_VAR(self);
+    CharBuf *class_name = TestBatch_Get_Class_Name(batch);
+    printf("Testing %s...\n", CB_Get_Ptr8(class_name));
+}
+
+void
+TestFormatterCF_vtest_result(TestFormatterCF *self, bool pass,
+                             uint32_t test_num, const char *fmt,
+                             va_list args) {
+    UNUSED_VAR(self);
+    if (!pass) {
+        printf("  Failed test %u: ", test_num);
+        vprintf(fmt, args);
+        printf("\n");
+    }
+}
+
+void
+TestFormatterCF_vtest_comment(TestFormatterCF *self, const char *fmt,
+                              va_list args) {
+    UNUSED_VAR(self);
+    printf("    ");
+    vprintf(fmt, args);
+}
+
+void
+TestFormatterCF_vbatch_comment(TestFormatterCF *self, const char *fmt,
+                               va_list args) {
+    UNUSED_VAR(self);
+    printf("  ");
+    vprintf(fmt, args);
+}
+
+void
+TestFormatterCF_summary(TestFormatterCF *self, TestRunner *runner) {
+    UNUSED_VAR(self);
+    uint32_t num_batches        = TestRunner_Get_Num_Batches(runner);
+    uint32_t num_batches_failed = TestRunner_Get_Num_Batches_Failed(runner);
+    uint32_t num_tests          = TestRunner_Get_Num_Tests(runner);
+    uint32_t num_tests_failed   = TestRunner_Get_Num_Tests_Failed(runner);
+
+    if (num_batches == 0) {
+        printf("No tests planned or run.\n");
+    }
+    else if (num_batches_failed == 0) {
+        printf("%u batches passed. %u tests passed.\n", num_batches,
+               num_tests);
+        printf("Result: PASS\n");
+    }
+    else {
+        printf("%u/%u batches failed. %u/%u tests failed.\n",
+               num_batches_failed, num_batches, num_tests_failed, num_tests);
+        printf("Result: FAIL\n");
+    }
+}
+
+TestFormatterTAP*
+TestFormatterTAP_new() {
+    TestFormatterTAP *self
+        = (TestFormatterTAP*)VTable_Make_Obj(TESTFORMATTERTAP);
+    return TestFormatterTAP_init(self);
+}
+
+TestFormatterTAP*
+TestFormatterTAP_init(TestFormatterTAP *self) {
+    return (TestFormatterTAP*)TestFormatter_init((TestFormatter*)self);
+}
+
+void
+TestFormatterTAP_batch_prologue(TestFormatterTAP *self, TestBatch *batch) {
+    UNUSED_VAR(self);
+    printf("1..%" PRId64 "\n", TestBatch_Get_Num_Planned(batch));
+}
+
+void
+TestFormatterTAP_vtest_result(TestFormatterTAP *self, bool pass,
+                              uint32_t test_num, const char *fmt,
+                              va_list args) {
+    UNUSED_VAR(self);
+    const char *result = pass ? "ok" : "not ok";
+    printf("%s %d - ", result, test_num);
+    vprintf(fmt, args);
+    printf("\n");
+}
+
+void
+TestFormatterTAP_vtest_comment(TestFormatterTAP *self, const char *fmt,
+                               va_list args) {
+    UNUSED_VAR(self);
+    printf("#   ");
+    vprintf(fmt, args);
+}
+
+void
+TestFormatterTAP_vbatch_comment(TestFormatterTAP *self, const char *fmt,
+                                va_list args) {
+    UNUSED_VAR(self);
+    printf("# ");
+    vprintf(fmt, args);
+}
+
+void
+TestFormatterTAP_summary(TestFormatterTAP *self, TestRunner *runner) {
+    UNUSED_VAR(self);
+    UNUSED_VAR(runner);
+}
+
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Clownfish/Test/TestFormatter.cfh
----------------------------------------------------------------------
diff --git a/core/Clownfish/Test/TestFormatter.cfh b/core/Clownfish/Test/TestFormatter.cfh
index 3584ba8..4487b37 100644
--- a/core/Clownfish/Test/TestFormatter.cfh
+++ b/core/Clownfish/Test/TestFormatter.cfh
@@ -75,4 +75,64 @@ abstract class Clownfish::Test::TestFormatter inherits Clownfish::Obj {
     Summary(TestFormatter *self, TestRunner *runner);
 }
 
+/**
+ * A TestFormatter that produces human-readable output in a custom
+ * "Clownfish" format.
+ */
+class Clownfish::Test::Formatter::TestFormatterCF
+    inherits Clownfish::Test::TestFormatter {
+
+    inert incremented TestFormatterCF*
+    new();
+
+    inert TestFormatterCF*
+    init(TestFormatterCF *self);
+
+    void
+    Batch_Prologue(TestFormatterCF *self, TestBatch *batch);
+
+    void
+    VTest_Result(TestFormatterCF *self, bool pass, uint32_t test_num,
+                 const char *fmt, va_list args);
+
+    void
+    VTest_Comment(TestFormatterCF *self, const char *fmt, va_list args);
+
+    void
+    VBatch_Comment(TestFormatterCF *self, const char *fmt, va_list args);
+
+    void
+    Summary(TestFormatterCF *self, TestRunner *runner);
+}
+
+/**
+ * A TestFormatter that produces TAP output (Test Anything Protocol).
+ * See http://testanything.org/
+ */
+class Clownfish::Test::Formatter::TestFormatterTAP
+    inherits Clownfish::Test::TestFormatter {
+
+    inert incremented TestFormatterTAP*
+    new();
+
+    inert TestFormatterTAP*
+    init(TestFormatterTAP *self);
+
+    void
+    Batch_Prologue(TestFormatterTAP *self, TestBatch *batch);
+
+    void
+    VTest_Result(TestFormatterTAP *self, bool pass, uint32_t test_num,
+                 const char *fmt, va_list args);
+
+    void
+    VTest_Comment(TestFormatterTAP *self, const char *fmt, va_list args);
+
+    void
+    VBatch_Comment(TestFormatterTAP *self, const char *fmt, va_list args);
+
+    void
+    Summary(TestFormatterTAP *self, TestRunner *runner);
+}
+
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/4857ea76/core/Lucy/Test.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test.c b/core/Lucy/Test.c
index ec219a7..aec89d5 100644
--- a/core/Lucy/Test.c
+++ b/core/Lucy/Test.c
@@ -23,7 +23,6 @@
 #include "Lucy/Util/ToolSet.h"
 
 #include "Lucy/Test.h"
-#include "Clownfish/Test/Formatter/TestFormatterTAP.h"
 #include "Clownfish/Test/TestFormatter.h"
 #include "Clownfish/Test/TestRunner.h"
 #include "Lucy/Test/Highlight/TestHeatMap.h"