You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2006/11/04 09:32:35 UTC

svn commit: r471139 - in /lucene/lucy/trunk/charmonizer: ./ src/Charmonizer/ src/Charmonizer/Test/

Author: marvin
Date: Sat Nov  4 00:32:35 2006
New Revision: 471139

URL: http://svn.apache.org/viewvc?view=rev&rev=471139
Log:
Move specific test function declarations into AllTests, and out of Test -- so
Test can be a general module.

Added:
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.harm
Modified:
    lucene/lucy/trunk/charmonizer/charm_test.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.harm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Headers.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Integers.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/UnusedVars.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm

Modified: lucene/lucy/trunk/charmonizer/charm_test.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charm_test.c?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/charm_test.c (original)
+++ lucene/lucy/trunk/charmonizer/charm_test.c Sat Nov  4 00:32:35 2006
@@ -1,40 +1,11 @@
 #include <stdio.h>
-#include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 
 int main() {
-    int total_tests   = 0;
-    int total_passed  = 0;
-    int total_failed  = 0;
-    int total_skipped = 0;
-    int i;
-    chaz_TestBatch* batches[7];
 
-    chaz_Test_init();
+    chaz_AllTests_init();
+    chaz_AllTests_run();
 
-    batches[0] = chaz_TFuncMacro_prepare();
-    batches[1] = chaz_THeaders_prepare();
-    batches[2] = chaz_TIntegers_prepare();
-    batches[3] = chaz_TLargeFiles_prepare();
-    batches[4] = chaz_TUnusedVars_prepare();
-    batches[5] = chaz_TVariadicMacros_prepare();
-    batches[6] = NULL;
-    
-    /* loop through test functions, accumulating results */
-    for (i = 0; batches[i] != NULL; i++) {
-        chaz_TestBatch *batch = batches[i];
-        batch->run_test(batch);
-        total_tests    += batch->num_tests;
-        total_passed   += batch->num_passed;
-        total_failed   += batch->num_failed;
-        total_skipped  += batch->num_skipped;
-        batch->destroy(batch);
-    }
-    
-    /* print totals */
-    printf("=============================\n");
-    printf("TOTAL TESTS:   %d\nTOTAL PASSED:  %d\nTOTAL FAILED:  %d\n"
-        "TOTAL SKIPPED: %d\n", 
-        total_tests, total_passed, total_failed, total_skipped);
     return 0;
 }
 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.harm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test.harm Sat Nov  4 00:32:35 2006
@@ -47,58 +47,6 @@
 chaz_Test_new_batch(const char *batch_name, unsigned num_tests,
 				    chaz_TestBatch_test_func_t test_func);
 
-/* These tests all require the file charmony.h.  See the documentation for
- * Charmonizer/Probe.h for instructions on how to produce it.
- *
- * No other header files should be included other than charmony.h and this
- * one.
- * 
- * Since Charmonizer conditionally defines many symbols, it can be difficult
- * to tell whether a symbol is missing because it should not have been
- * generated, or whether it is missing because an error occurred.  These test
- * functions make the assumption that any missing symbols have a good excuse
- * for their absence, and test only defined symbols.  This may result in
- * undetected failure some of the time.  However, missing symbols required by
- * your application will trigger compile-time errors, so the theoretical
- * problem of silent failure is less severe than it appears, affecting only
- * fallbacks.
- */
-chaz_TestBatch* 
-chaz_TFuncMacro_prepare();
-
-chaz_TestBatch* 
-chaz_THeaders_prepare();
-
-chaz_TestBatch* 
-chaz_TIntegers_prepare();
-
-chaz_TestBatch* 
-chaz_TLargeFiles_prepare();
-
-chaz_TestBatch* 
-chaz_TUnusedVars_prepare();
-
-chaz_TestBatch* 
-chaz_TVariadicMacros_prepare();
-
-void
-chaz_TFuncMacro_run(chaz_TestBatch *batch);
-
-void
-chaz_THeaders_run(chaz_TestBatch *batch);
-
-void
-chaz_TIntegers_run(chaz_TestBatch *batch);
-
-void
-chaz_TLargeFiles_run(chaz_TestBatch *batch);
-
-void
-chaz_TUnusedVars_run(chaz_TestBatch *batch);
-
-void
-chaz_TVariadicMacros_run(chaz_TestBatch *batch);
-
 /* Note: maybe add line numbers later.
  */
 #define CHAZ_TEST_ASSERT_TRUE       chaz_Test_assert_true

Added: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.charm?view=auto&rev=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.charm (added)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.charm Sat Nov  4 00:32:35 2006
@@ -0,0 +1,74 @@
+#define CHAZ_USE_SHORT_NAMES
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "Charmonizer/Test/AllTests.h"
+    
+static TestBatch **batches = NULL;
+
+void
+chaz_AllTests_init()
+{
+    chaz_Test_init();
+
+    batches = malloc(7 * sizeof(TestBatch*));
+
+    batches[0] = chaz_TFuncMacro_prepare();
+    batches[1] = chaz_THeaders_prepare();
+    batches[2] = chaz_TIntegers_prepare();
+    batches[3] = chaz_TLargeFiles_prepare();
+    batches[4] = chaz_TUnusedVars_prepare();
+    batches[5] = chaz_TVariadicMacros_prepare();
+    batches[6] = NULL;
+}
+
+void
+chaz_AllTests_run()
+{
+    int total_tests   = 0;
+    int total_passed  = 0;
+    int total_failed  = 0;
+    int total_skipped = 0;
+    int i;
+    
+    if (batches == NULL) {
+        fprintf(stderr, "Must call AllTests_init() first.");
+        exit(1);
+    }
+
+    /* loop through test functions, accumulating results */
+    for (i = 0; batches[i] != NULL; i++) {
+        chaz_TestBatch *batch = batches[i];
+        batch->run_test(batch);
+        total_tests    += batch->num_tests;
+        total_passed   += batch->num_passed;
+        total_failed   += batch->num_failed;
+        total_skipped  += batch->num_skipped;
+        batch->destroy(batch);
+    }
+    
+    /* print totals */
+    printf("=============================\n");
+    printf("TOTAL TESTS:   %d\nTOTAL PASSED:  %d\nTOTAL FAILED:  %d\n"
+        "TOTAL SKIPPED: %d\n", 
+        total_tests, total_passed, total_failed, total_skipped);
+
+}
+
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+

Added: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.harm?view=auto&rev=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.harm (added)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/AllTests.harm Sat Nov  4 00:32:35 2006
@@ -0,0 +1,88 @@
+/* Charmonizer/Test.h - test Charmonizer's output.
+ */
+
+#ifndef H_CHAZ_ALL_TESTS
+#define H_CHAZ_ALL_TESTS
+
+#include "Charmonizer/Test.h"
+
+/* Initialize the AllTests module.
+ */
+void
+chaz_AllTests_init();
+
+/* Run all tests.
+ */
+void
+chaz_AllTests_run();
+
+/* These tests all require the file charmony.h.
+ * 
+ * Since Charmonizer conditionally defines many symbols, it can be difficult
+ * to tell whether a symbol is missing because it should not have been
+ * generated, or whether it is missing because an error occurred.  These test
+ * functions make the assumption that any missing symbols have a good excuse
+ * for their absence, and test only defined symbols.  This may result in
+ * undetected failure some of the time.  However, missing symbols required by
+ * your application will trigger compile-time errors, so the theoretical
+ * problem of silent failure is less severe than it appears, affecting only
+ * fallbacks.
+ */
+chaz_TestBatch* 
+chaz_TFuncMacro_prepare();
+
+chaz_TestBatch* 
+chaz_THeaders_prepare();
+
+chaz_TestBatch* 
+chaz_TIntegers_prepare();
+
+chaz_TestBatch* 
+chaz_TLargeFiles_prepare();
+
+chaz_TestBatch* 
+chaz_TUnusedVars_prepare();
+
+chaz_TestBatch* 
+chaz_TVariadicMacros_prepare();
+
+void
+chaz_TFuncMacro_run(chaz_TestBatch *batch);
+
+void
+chaz_THeaders_run(chaz_TestBatch *batch);
+
+void
+chaz_TIntegers_run(chaz_TestBatch *batch);
+
+void
+chaz_TLargeFiles_run(chaz_TestBatch *batch);
+
+void
+chaz_TUnusedVars_run(chaz_TestBatch *batch);
+
+void
+chaz_TVariadicMacros_run(chaz_TestBatch *batch);
+
+#ifdef CHAZ_USE_SHORT_NAMES
+#endif
+
+#endif /* H_CHAZ_TEST */
+
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm Sat Nov  4 00:32:35 2006
@@ -3,6 +3,7 @@
 #include "charmony.h"
 #include <string.h>
 #include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 
 TestBatch*
 chaz_TFuncMacro_prepare()

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Headers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Headers.charm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Headers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Headers.charm Sat Nov  4 00:32:35 2006
@@ -3,6 +3,7 @@
 #include "charmony.h"
 #include <string.h>
 #include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 
 #ifdef HAS_ASSERT_H
   #include <assert.h>

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Integers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Integers.charm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/Integers.charm Sat Nov  4 00:32:35 2006
@@ -1,6 +1,7 @@
 #define CHAZ_USE_SHORT_NAMES
 
 #include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 #include "charmony.h"
 #include <stdio.h>
 #include <string.h>

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm Sat Nov  4 00:32:35 2006
@@ -8,6 +8,7 @@
 
 #include <stdio.h>
 #include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 
 TestBatch*
 chaz_TLargeFiles_prepare()

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/UnusedVars.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/UnusedVars.charm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/UnusedVars.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/UnusedVars.charm Sat Nov  4 00:32:35 2006
@@ -2,6 +2,7 @@
 
 #include "charmony.h"
 #include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 
 TestBatch*
 chaz_TUnusedVars_prepare()

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm?view=diff&rev=471139&r1=471138&r2=471139
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm Sat Nov  4 00:32:35 2006
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <stdio.h>
 #include "Charmonizer/Test.h"
+#include "Charmonizer/Test/AllTests.h"
 
 TestBatch*
 chaz_TVariadicMacros_prepare()