corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmke...@apache.org
Subject incubator-corinthia git commit: Move test harness from dfutil to dftest
Date Sun, 21 Dec 2014 03:48:54 GMT
Repository: incubator-corinthia
Updated Branches:
  refs/heads/master 58f9d3884 -> 585a483c5


Move test harness from dfutil to dftest

The 'dftest' program is the new home of the test harness for running
data tests (those which are invoked from .test files), in addition to
plain tests (those which require no data files, and can be run simply by
calling their corresponding function).

Usage is as follows:

dftest path1 path2 ...

    Run a series of automated tests, consisting of all the .test files
    in the specified path(s). If only one file is found, the test is run
    and the result is printed to standard output. If multiple files are
    found, they are all run, and their pass/fail status is printed.

dftest -diff path1 path2 ...

    As above, but for each test that fails, print out a diff between the
    expected and actual results.

dftest -plain

    Run all tests functions of type PlainTest, which don't use any data
    files


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/585a483c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/585a483c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/585a483c

Branch: refs/heads/master
Commit: 585a483c558cf72a1377eb28184454e90b4eb254
Parents: 58f9d38
Author: Peter Kelly <peter@uxproductivity.com>
Authored: Sun Dec 21 10:45:06 2014 +0700
Committer: Peter Kelly <peter@uxproductivity.com>
Committed: Sun Dec 21 10:45:06 2014 +0700

----------------------------------------------------------------------
 DocFormats/unittest/DFUnitTest.c     |   3 +-
 consumers/dftest/src/CMakeLists.txt  |  24 +++
 consumers/dftest/src/main.c          | 338 +++++++++++++++++++++++++++++-
 consumers/dfutil/src/CMakeLists.txt  |   4 -
 consumers/dfutil/src/Commands.c      |  34 ---
 consumers/dfutil/src/Commands.h      |   1 -
 consumers/dfutil/src/Test.c          | 251 ----------------------
 consumers/dfutil/src/Test.h          |  37 ----
 consumers/dfutil/src/TestFunctions.c |  71 -------
 consumers/dfutil/src/TestFunctions.h |  20 --
 consumers/dfutil/src/main.c          |  13 --
 11 files changed, 361 insertions(+), 435 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/DocFormats/unittest/DFUnitTest.c
----------------------------------------------------------------------
diff --git a/DocFormats/unittest/DFUnitTest.c b/DocFormats/unittest/DFUnitTest.c
index d222ff9..65a47d9 100644
--- a/DocFormats/unittest/DFUnitTest.c
+++ b/DocFormats/unittest/DFUnitTest.c
@@ -44,7 +44,8 @@ static void runGroup(TestGroup *group)
 {
     printf("Test group: %s\n",group->name);
     for (int i = 0; group->tests[i].name; i++) {
-        runTest(&group->tests[i]);
+        if (group->tests[i].type == PlainTest)
+            runTest(&group->tests[i]);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dftest/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/consumers/dftest/src/CMakeLists.txt b/consumers/dftest/src/CMakeLists.txt
index 556d47a..a56bbd0 100644
--- a/consumers/dftest/src/CMakeLists.txt
+++ b/consumers/dftest/src/CMakeLists.txt
@@ -8,5 +8,29 @@ include_directories(.)
 include_directories(../../../DocFormats/unittest)
 link_directories(${LIB_DIRS})
 
+include_directories(SYSTEM ../../../DocFormats/api/headers)
+include_directories(../../../DocFormats)
+include_directories(../../../DocFormats/unittest)
+include_directories(../../../DocFormats/platform/headers)
+include_directories(../../../DocFormats/core/src/common)
+include_directories(../../../DocFormats/core/src/css)
+include_directories(../../../DocFormats/core/src/html)
+include_directories(../../../DocFormats/core/src/lib)
+include_directories(../../../DocFormats/core/src/names)
+include_directories(../../../DocFormats/core/src/xml)
+include_directories(../../../DocFormats/core/tests/html)
+include_directories(../../../DocFormats/core/tests/common)
+include_directories(../../../DocFormats/filters/latex/src)
+include_directories(../../../DocFormats/filters/odf/src)
+include_directories(../../../DocFormats/filters/ooxml/src/common)
+include_directories(../../../DocFormats/filters/ooxml/src/word)
+include_directories(../../../DocFormats/filters/ooxml/src/word/formatting)
+include_directories(../../../DocFormats/filters/ooxml/src/word/lenses)
+include_directories(../../../DocFormats/filters/ooxml/tests/word)
+include_directories(/usr/include/libxml2)
+
+
 add_executable(dftest ${SOURCES})
 target_link_libraries(dftest DocFormats ${LIBS})
+
+source_group(\\ FILES ${SOURCES})

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dftest/src/main.c
----------------------------------------------------------------------
diff --git a/consumers/dftest/src/main.c b/consumers/dftest/src/main.c
index dbf6447..8ea8e76 100644
--- a/consumers/dftest/src/main.c
+++ b/consumers/dftest/src/main.c
@@ -13,7 +13,20 @@
 // limitations under the License.
 
 #include "DFUnitTest.h"
+#include "TextPackage.h"
+#include "DFString.h"
+#include "DFFilesystem.h"
+#include "DFCommon.h"
+#include "DFUnitTest.h"
+#include "DFArray.h"
+#include "DFBuffer.h"
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#ifndef WIN32
+#include <unistd.h>
+#endif
 
 extern TestGroup APITests;
 extern TestGroup CSSTests;
@@ -24,9 +37,11 @@ extern TestGroup LaTeXTests;
 extern TestGroup ODFTests;
 extern TestGroup WordTests;
 extern TestGroup PlatformTests;
+extern TestGroup BDTTests;
 
-TestGroup *groups[] = {
+TestGroup *allGroups[] = {
     &APITests,
+    &BDTTests,
     &CSSTests,
     &HTMLTests,
     &LibTests,
@@ -38,10 +53,327 @@ TestGroup *groups[] = {
     NULL
 };
 
+typedef struct {
+    int showResults;
+    int showDiffs;
+    int passed;
+    int failed;
+} TestHarness;
+
+char *createTempDir(DFError **error)
+{
+#ifdef WIN32
+    // Windows lacks mkdtemp. For the purposes of a single-threaded app it's ok just to use
the same name
+    // each time we do a conversion, as long as we ensure that the directory is cleared first.
+    const char *name = "dfutil.temp";
+    if (DFFileExists(name) && !DFDeleteFile(name,error))
+        return NULL;
+    if (!DFCreateDirectory(name,1,error))
+        return NULL;
+    return strdup(name);
+#else
+    char *ctemplate = strdup("dfutil.XXXXXX");
+    char *r = mkdtemp(ctemplate);
+    if (r == NULL) {
+        DFErrorFormat(error,"mkdtemp: %s",strerror(errno));
+        free(ctemplate);
+        return NULL;
+    }
+    return ctemplate;
+#endif
+}
+
+static int diffResults2(const char *from, const char *to, const char *tempDir, DFError **error)
+{
+    char *fromFilename = DFAppendPathComponent(tempDir,"from");
+    char *toFilename = DFAppendPathComponent(tempDir,"to");
+    int result = 0;
+    if (!DFStringWriteToFile(from,fromFilename,error)) {
+        DFErrorFormat(error,"%s: %s",fromFilename,DFErrorMessage(error));
+    }
+    else if (!DFStringWriteToFile(to,toFilename,error)) {
+        DFErrorFormat(error,"%s: %s",toFilename,DFErrorMessage(error));
+    }
+    else {
+        char *cmd = DFFormatString("diff -u %s/from %s/to",tempDir,tempDir);
+        system(cmd);
+        free(cmd);
+        result = 1;
+    }
+    free(fromFilename);
+    free(toFilename);
+    return result;
+}
+
+static int diffResults(const char *from, const char *to, DFError **error)
+{
+    char *tempDir = createTempDir(error);
+    if (tempDir == NULL)
+        return 0;
+
+    int result = diffResults2(from,to,tempDir,error);
+    DFDeleteFile(tempDir,NULL);
+    free(tempDir);
+    return result;
+}
+
+static char *getCommandFromCode(const char *code, DFError **error)
+{
+    char *command = NULL;
+    const char **lines = DFStringSplit(code,"\n",0);
+    int count = 0;
+    for (int i = 0; lines[i]; i++) {
+        if (!DFStringIsWhitespace(lines[i]) && strncmp(lines[i],"//",2)) {
+            if (command == NULL)
+                command = strdup(lines[i]);
+            count++;
+        }
+    }
+    free(lines);
+
+    if (count != 1) {
+        DFErrorFormat(error,"%d commands found",count);
+        free(command);
+        return NULL;
+    }
+    else {
+        return command;
+    }
+}
+
+static const char **parseCommand(const char *command, DFError **error)
+{
+    const char *openbr = strchr(command,'(');
+    const char *closebr = strrchr(command,')');
+
+    if ((openbr == NULL) && (closebr == NULL)) {
+        DFArray *array = DFArrayNew((DFCopyFunction)strdup,free);
+        DFArrayAppend(array,(void *)command);
+        const char **result = DFStringArrayFlatten(array);
+        DFArrayRelease(array);
+        return result;
+    }
+
+    if ((openbr == NULL) || (closebr == NULL)) {
+        DFErrorFormat(error,"Malformed command: %s\n",command);
+        return NULL;
+    }
+
+    size_t openpos = openbr - command;
+    size_t closepos = closebr - command;
+    size_t nameend = openpos;
+
+    if ((openpos+2 <= closepos) && (command[openpos+1] == '{') && (command[closepos-1]
== '}')) {
+        openpos++;
+        closepos--;
+    }
+
+    char *name = DFSubstring(command,0,nameend);
+    char *arguments = DFSubstring(command,openpos+1,closepos);
+
+    const char **components = DFStringSplit(arguments,",",0);
+    DFArray *array = DFArrayNew((DFCopyFunction)strdup,free);
+    DFArrayAppend(array,name);
+    for (int i = 0; components[i]; i++) {
+        char *trimmed = DFStringTrimWhitespace(components[i]);
+        DFArrayAppend(array,trimmed);
+        free(trimmed);
+    }
+
+    const char **result = DFStringArrayFlatten(array);
+
+    free(components);
+    free(name);
+    free(arguments);
+    DFArrayRelease(array);
+    return result;
+}
+
+static void TestRun(TestHarness *harness, const char *path)
+{
+    DFError *error = NULL;
+    TextPackage *package = TextPackageNewWithFile(path,&error);
+    int pass = 0;
+    if (package != NULL) {
+        DFHashTable *dict = DFHashTableCopy(package->items);
+
+        char *code = DFStrDup(DFHashTableLookup(dict,""));
+        DFHashTableRemove(dict,"");
+
+        char *command = getCommandFromCode(code,&error);
+        if (command == NULL) {
+            printf("%s: %s\n",path,DFErrorMessage(&error));
+            exit(1);
+        }
+
+        const char **arguments = parseCommand(command,&error);
+        if (arguments == NULL) {
+            printf("%s: %s\n",path,DFErrorMessage(&error));
+            exit(1);
+        }
+
+        char *expectedRaw = DFStrDup(DFHashTableLookup(dict,"expected"));
+        if (expectedRaw == NULL) {
+            printf("%s: no expected output given\n",path);
+            exit(1);
+        }
+        DFHashTableRemove(dict,"expected");
+
+        char *parentPath = DFPathDirName(path);
+        DFBuffer *outputBuf = DFBufferNew();
+        utsetup(parentPath,dict,(int)(DFStringArrayCount(arguments)-1),&arguments[1],
+                outputBuf);
+
+        TestCase *tc = utlookup(allGroups,arguments[0]);
+        if (tc != NULL) {
+            tc->fun();
+        }
+        else {
+            DFBufferFormat(utgetoutput(),"Unknown test: %s\n",arguments[0]);
+        }
+
+        char *output = DFStringTrimWhitespace(outputBuf->data);
+        char *expected = DFStringTrimWhitespace(expectedRaw);
+
+        if (harness->showResults && !harness->showDiffs) {
+            printf("%s",outputBuf->data);
+        }
+        else {
+            pass = ((expected != NULL) && DFStringEquals(expected,output));
+        }
+
+        if (!pass && harness->showDiffs) {
+            if (!diffResults(expected,output,&error))
+                printf("%s\n",DFErrorMessage(&error));
+        }
+
+        free(output);
+        free(code);
+        free(command);
+        free(arguments);
+        free(expectedRaw);
+        free(parentPath);
+        free(expected);
+        utteardown();
+        DFBufferRelease(outputBuf);
+        DFHashTableRelease(dict);
+    }
+    else {
+        if (harness->showResults || harness->showDiffs)
+            printf("%s\n",DFErrorMessage(&error));
+    }
+
+    if (!harness->showResults) {
+        if (pass) {
+            printf("%-80s PASS\n",path);
+            harness->passed++;
+        }
+        else {
+            printf("%-80s FAIL\n",path);
+            harness->failed++;
+        }
+    }
+    TextPackageRelease(package);
+}
+
+static void TestGetFilenamesRecursive(const char *path, DFArray *result)
+{
+    if (!DFFileExists(path))
+        return;
+    int isDirectory = DFIsDirectory(path);
+    if (isDirectory) {
+        DFError *error = NULL;
+        const char **contents = DFContentsOfDirectory(path,0,&error);
+        if (contents == NULL) {
+            printf("%s: %s\n",path,DFErrorMessage(&error));
+            DFErrorRelease(error);
+            return;
+        }
+
+        DFSortStringsCaseInsensitive(contents);
+
+        for (int i = 0; contents[i]; i++) {
+            const char *filename = contents[i];
+            char *childPath = DFAppendPathComponent(path,filename);
+            TestGetFilenamesRecursive(childPath,result);
+            free(childPath);
+        }
+        free(contents);
+    }
+    else {
+        char *extension = DFPathExtension(path);
+        if (DFStringEqualsCI(extension,"test"))
+            DFArrayAppend(result,(void *)path);
+        free(extension);
+    }
+}
+
+void runTests(int argc, const char **argv, int diff)
+{
+    DFArray *tests = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
+    for (int i = 0; i < argc; i++) {
+        const char *path = argv[i];
+        if (!DFFileExists(path)) {
+            fprintf(stderr,"%s: No such file or directory\n",path);
+            exit(1);
+        }
+        TestGetFilenamesRecursive(path,tests);
+    }
+
+    TestHarness harness;
+    bzero(&harness,sizeof(TestHarness));
+    harness.showResults = (DFArrayCount(tests) == 1);
+    harness.showDiffs = diff;
+
+    if (DFArrayCount(tests) == 1) {
+        TestRun(&harness,(const char *)DFArrayItemAt(tests,0));
+    }
+    else {
+        for (size_t i = 0; i < DFArrayCount(tests); i++) {
+            const char *test = DFArrayItemAt(tests,i);
+            TestRun(&harness,test);
+        }
+        printf("Passed: %d\n",harness.passed);
+        printf("Failed: %d\n",harness.failed);
+    }
+    DFArrayRelease(tests);
+}
+
 int main(int argc, const char **argv)
 {
+    // Ensure that if a segfault occurs half-way through printing a line,
+    // we still get the partial output.
     setbuf(stdout,NULL);
-    // For now, just run the 'plain' tests.
-    utrun(groups,1,0,NULL);
+
+    if ((argc == 2) && !strcmp(argv[1],"-plain")) {
+        utrun(allGroups,1,0,NULL);
+    }
+    else if ((argc >= 3) && !strcmp(argv[1],"-diff")) {
+        runTests(argc-2,&argv[2],1);
+    }
+    else if (argc >= 2) {
+        runTests(argc-1,&argv[1],0);
+    }
+    else {
+        // Usage
+        printf("Usage:\n"
+               "\n"
+               "dftest path1 path2 ...\n"
+               "\n"
+               "    Run a series of automated tests, consisting of all the .test files in
the\n"
+               "    specified path(s). If only one file is found, the test is run and the\n"
+               "    result is printed to standard output. If multiple files are found, they
are\n"
+               "    all run, and their pass/fail status is printed.\n"
+               "\n"
+               "dftest -diff path1 path2 ...\n"
+               "\n"
+               "    As above, but for each test that fails, print out a diff between the
expected\n"
+               "    and actual results.\n"
+               "\n"
+               "dftest -plain\n"
+               "\n"
+               "    Run all tests functions of type PlainTest, which don't use any data files\n"
+               "\n");
+    }
     return 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/CMakeLists.txt b/consumers/dfutil/src/CMakeLists.txt
index 1ebc8fd..2107b92 100644
--- a/consumers/dfutil/src/CMakeLists.txt
+++ b/consumers/dfutil/src/CMakeLists.txt
@@ -5,10 +5,6 @@ set(SOURCES
     Commands.h
     FunctionTests.h
     StringTests.h
-    Test.c
-    Test.h
-    TestFunctions.c
-    TestFunctions.h
     main.c
 )
 

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/Commands.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Commands.c b/consumers/dfutil/src/Commands.c
index 81e8221..626ff93 100644
--- a/consumers/dfutil/src/Commands.c
+++ b/consumers/dfutil/src/Commands.c
@@ -14,7 +14,6 @@
 
 #include "Commands.h"
 #include "BDTTests.h"
-#include "Test.h"
 #include "WordPlain.h"
 #include "HTMLPlain.h"
 #include "TextPackage.h"
@@ -335,39 +334,6 @@ int textPackageGet(const char *filename, const char *itemPath, DFError
**error)
     return 1;
 }
 
-int runTests(int argc, const char **argv, int diff, DFError **error)
-{
-    DFArray *tests = DFArrayNew((DFCopyFunction)strdup,(DFFreeFunction)free);
-    for (int i = 0; i < argc; i++) {
-        const char *path = argv[i];
-        if (!DFFileExists(path)) {
-            DFErrorFormat(error,"%s: No such file or directory",path);
-            DFArrayRelease(tests);
-            return 0;
-        }
-        TestGetFilenamesRecursive(path,tests);
-    }
-
-    TestHarness harness;
-    bzero(&harness,sizeof(TestHarness));
-    harness.showResults = (DFArrayCount(tests) == 1);
-    harness.showDiffs = diff;
-
-    if (DFArrayCount(tests) == 1) {
-        TestRun(&harness,(const char *)DFArrayItemAt(tests,0));
-    }
-    else {
-        for (size_t i = 0; i < DFArrayCount(tests); i++) {
-            const char *test = DFArrayItemAt(tests,i);
-            TestRun(&harness,test);
-        }
-        printf("Passed: %d\n",harness.passed);
-        printf("Failed: %d\n",harness.failed);
-    }
-    DFArrayRelease(tests);
-    return 1;
-}
-
 int diffFiles(const char *filename1, const char *filename2, DFError **error)
 {
     DFDocument *doc1 = DFParseHTMLFile(filename1,0,error);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/Commands.h
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Commands.h b/consumers/dfutil/src/Commands.h
index e46cdde..e8acef8 100644
--- a/consumers/dfutil/src/Commands.h
+++ b/consumers/dfutil/src/Commands.h
@@ -25,7 +25,6 @@ int testCSS(const char *filename, DFError **error);
 int parseHTMLFile(const char *filename, DFError **error);
 int textPackageList(const char *filename, DFError **error);
 int textPackageGet(const char *filename, const char *itemPath, DFError **error);
-int runTests(int argc, const char **argv, int diff, DFError **error);
 int printTree(const char *filename, DFError **error);
 int diffFiles(const char *filename1, const char *filename2, DFError **error);
 void parseContent(const char *content);

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/Test.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Test.c b/consumers/dfutil/src/Test.c
deleted file mode 100644
index 322bbe2..0000000
--- a/consumers/dfutil/src/Test.c
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright 2012-2014 UX Productivity Pty Ltd
-//
-// 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.
-
-#include "Test.h"
-#include "TextPackage.h"
-#include "Commands.h"
-#include "TestFunctions.h"
-#include "DFString.h"
-#include "DFFilesystem.h"
-#include "DFCommon.h"
-#include "DFUnitTest.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                      
         //
-//                                           TestHarness                                
         //
-//                                                                                      
         //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int diffResults2(const char *from, const char *to, const char *tempDir, DFError **error)
-{
-    char *fromFilename = DFAppendPathComponent(tempDir,"from");
-    char *toFilename = DFAppendPathComponent(tempDir,"to");
-    int result = 0;
-    if (!DFStringWriteToFile(from,fromFilename,error)) {
-        DFErrorFormat(error,"%s: %s",fromFilename,DFErrorMessage(error));
-    }
-    else if (!DFStringWriteToFile(to,toFilename,error)) {
-        DFErrorFormat(error,"%s: %s",toFilename,DFErrorMessage(error));
-    }
-    else {
-        char *cmd = DFFormatString("diff -u %s/from %s/to",tempDir,tempDir);
-        system(cmd);
-        free(cmd);
-        result = 1;
-    }
-    free(fromFilename);
-    free(toFilename);
-    return result;
-}
-
-static int diffResults(const char *from, const char *to, DFError **error)
-{
-    char *tempDir = createTempDir(error);
-    if (tempDir == NULL)
-        return 0;
-
-    int result = diffResults2(from,to,tempDir,error);
-    DFDeleteFile(tempDir,NULL);
-    free(tempDir);
-    return result;
-}
-
-static char *getCommandFromCode(const char *code, DFError **error)
-{
-    char *command = NULL;
-    const char **lines = DFStringSplit(code,"\n",0);
-    int count = 0;
-    for (int i = 0; lines[i]; i++) {
-        if (!DFStringIsWhitespace(lines[i]) && strncmp(lines[i],"//",2)) {
-            if (command == NULL)
-                command = strdup(lines[i]);
-            count++;
-        }
-    }
-    free(lines);
-
-    if (count != 1) {
-        DFErrorFormat(error,"%d commands found",count);
-        free(command);
-        return NULL;
-    }
-    else {
-        return command;
-    }
-}
-
-static const char **parseCommand(const char *command, DFError **error)
-{
-    const char *openbr = strchr(command,'(');
-    const char *closebr = strrchr(command,')');
-
-    if ((openbr == NULL) && (closebr == NULL)) {
-        DFArray *array = DFArrayNew((DFCopyFunction)strdup,free);
-        DFArrayAppend(array,(void *)command);
-        const char **result = DFStringArrayFlatten(array);
-        DFArrayRelease(array);
-        return result;
-    }
-
-    if ((openbr == NULL) || (closebr == NULL)) {
-        DFErrorFormat(error,"Malformed command: %s\n",command);
-        return NULL;
-    }
-
-    size_t openpos = openbr - command;
-    size_t closepos = closebr - command;
-    size_t nameend = openpos;
-
-    if ((openpos+2 <= closepos) && (command[openpos+1] == '{') && (command[closepos-1]
== '}')) {
-        openpos++;
-        closepos--;
-    }
-
-    char *name = DFSubstring(command,0,nameend);
-    char *arguments = DFSubstring(command,openpos+1,closepos);
-
-    const char **components = DFStringSplit(arguments,",",0);
-    DFArray *array = DFArrayNew((DFCopyFunction)strdup,free);
-    DFArrayAppend(array,name);
-    for (int i = 0; components[i]; i++) {
-        char *trimmed = DFStringTrimWhitespace(components[i]);
-        DFArrayAppend(array,trimmed);
-        free(trimmed);
-    }
-
-    const char **result = DFStringArrayFlatten(array);
-
-    free(components);
-    free(name);
-    free(arguments);
-    DFArrayRelease(array);
-    return result;
-}
-
-void TestRun(TestHarness *harness, const char *path)
-{
-//    @autoreleasepool {
-        DFError *error = NULL;
-        TextPackage *package = TextPackageNewWithFile(path,&error);
-        int pass = 0;
-        if (package != NULL) {
-            DFHashTable *dict = DFHashTableCopy(package->items);
-
-            char *code = DFStrDup(DFHashTableLookup(dict,""));
-            DFHashTableRemove(dict,"");
-
-            char *command = getCommandFromCode(code,&error);
-            if (command == NULL) {
-                printf("%s: %s\n",path,DFErrorMessage(&error));
-                exit(1);
-            }
-
-            const char **arguments = parseCommand(command,&error);
-            if (arguments == NULL) {
-                printf("%s: %s\n",path,DFErrorMessage(&error));
-                exit(1);
-            }
-
-            char *expectedRaw = DFStrDup(DFHashTableLookup(dict,"expected"));
-            if (expectedRaw == NULL) {
-                printf("%s: no expected output given\n",path);
-                exit(1);
-            }
-            DFHashTableRemove(dict,"expected");
-
-            char *parentPath = DFPathDirName(path);
-            DFBuffer *outputBuf = DFBufferNew();
-            utsetup(parentPath,dict,(int)(DFStringArrayCount(arguments)-1),&arguments[1],
-                    outputBuf);
-            runTest(arguments[0]);
-
-            char *output = DFStringTrimWhitespace(outputBuf->data);
-            char *expected = DFStringTrimWhitespace(expectedRaw);
-
-            if (harness->showResults && !harness->showDiffs) {
-                printf("%s",outputBuf->data);
-            }
-            else {
-                pass = ((expected != NULL) && DFStringEquals(expected,output));
-            }
-
-            if (!pass && harness->showDiffs) {
-                if (!diffResults(expected,output,&error))
-                    printf("%s\n",DFErrorMessage(&error));
-            }
-
-            free(output);
-            free(code);
-            free(command);
-            free(arguments);
-            free(expectedRaw);
-            free(parentPath);
-            free(expected);
-            utteardown();
-            DFBufferRelease(outputBuf);
-            DFHashTableRelease(dict);
-        }
-        else {
-            if (harness->showResults || harness->showDiffs)
-                printf("%s\n",DFErrorMessage(&error));
-        }
-
-        if (!harness->showResults) {
-            if (pass) {
-                printf("%-80s PASS\n",path);
-                harness->passed++;
-            }
-            else {
-                printf("%-80s FAIL\n",path);
-                harness->failed++;
-            }
-        }
-        TextPackageRelease(package);
-//    }
-}
-
-void TestGetFilenamesRecursive(const char *path, DFArray *result)
-{
-    if (!DFFileExists(path))
-        return;
-    int isDirectory = DFIsDirectory(path);
-    if (isDirectory) {
-        DFError *error = NULL;
-        const char **contents = DFContentsOfDirectory(path,0,&error);
-        if (contents == NULL) {
-            printf("%s: %s\n",path,DFErrorMessage(&error));
-            DFErrorRelease(error);
-            return;
-        }
-
-        DFSortStringsCaseInsensitive(contents);
-
-        for (int i = 0; contents[i]; i++) {
-            const char *filename = contents[i];
-            char *childPath = DFAppendPathComponent(path,filename);
-            TestGetFilenamesRecursive(childPath,result);
-            free(childPath);
-        }
-        free(contents);
-    }
-    else {
-        char *extension = DFPathExtension(path);
-        if (DFStringEqualsCI(extension,"test"))
-            DFArrayAppend(result,(void *)path);
-        free(extension);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/Test.h
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/Test.h b/consumers/dfutil/src/Test.h
deleted file mode 100644
index a7b913a..0000000
--- a/consumers/dfutil/src/Test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2012-2014 UX Productivity Pty Ltd
-//
-// 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.
-
-#ifndef dfutil_Test_h
-#define dfutil_Test_h
-
-#include "DFArray.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-//                                                                                      
         //
-//                                           TestHarness                                
         //
-//                                                                                      
         //
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct {
-    int showResults;
-    int showDiffs;
-    int passed;
-    int failed;
-} TestHarness;
-
-void TestRun(TestHarness *harness, const char *path);
-
-void TestGetFilenamesRecursive(const char *path, DFArray *result);
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/TestFunctions.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/TestFunctions.c b/consumers/dfutil/src/TestFunctions.c
deleted file mode 100644
index 1d09a33..0000000
--- a/consumers/dfutil/src/TestFunctions.c
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2012-2014 UX Productivity Pty Ltd
-//
-// 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.
-
-#include "TestFunctions.h"
-#include "DFBDT.h"
-#include "BDTTests.h"
-#include "WordPlain.h"
-#include "HTMLPlain.h"
-#include "Commands.h"
-#include "DFChanges.h"
-#include "WordConverter.h"
-#include "Word.h"
-#include "DFHTML.h"
-#include "DFHTMLNormalization.h"
-#include "DFFilesystem.h"
-#include "DFString.h"
-#include "HTMLToLaTeX.h"
-#include "DFXML.h"
-#include "DFCommon.h"
-#include "DFUnitTest.h"
-#include <DocFormats/DocFormats.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern TestGroup APITests;
-extern TestGroup CSSTests;
-extern TestGroup HTMLTests;
-extern TestGroup LibTests;
-extern TestGroup XMLTests;
-extern TestGroup LaTeXTests;
-extern TestGroup ODFTests;
-extern TestGroup WordTests;
-extern TestGroup PlatformTests;
-extern TestGroup BDTTests;
-
-TestGroup *allGroups[] = {
-    &APITests,
-    &BDTTests,
-    &CSSTests,
-    &HTMLTests,
-    &LibTests,
-    &XMLTests,
-    &LaTeXTests,
-    &ODFTests,
-    &WordTests,
-    &PlatformTests,
-    NULL
-};
-
-void runTest(const char *name)
-{
-    TestCase *tc = utlookup(allGroups,name);
-    if (tc != NULL) {
-        tc->fun();
-        return;
-    }
-
-    DFBufferFormat(utgetoutput(),"Unknown test: %s\n",name);
-}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/TestFunctions.h
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/TestFunctions.h b/consumers/dfutil/src/TestFunctions.h
deleted file mode 100644
index d98d59d..0000000
--- a/consumers/dfutil/src/TestFunctions.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012-2014 UX Productivity Pty Ltd
-//
-// 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.
-
-#ifndef dfutil_TestFunctions_h
-#define dfutil_TestFunctions_h
-
-void runTest(const char *name);
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/585a483c/consumers/dfutil/src/main.c
----------------------------------------------------------------------
diff --git a/consumers/dfutil/src/main.c b/consumers/dfutil/src/main.c
index 21b95a2..1812f2d 100644
--- a/consumers/dfutil/src/main.c
+++ b/consumers/dfutil/src/main.c
@@ -14,7 +14,6 @@
 
 #include "Commands.h"
 #include "BDTTests.h"
-#include "Test.h"
 #include "WordPlain.h"
 #include "HTMLPlain.h"
 #include "FunctionTests.h"
@@ -38,12 +37,6 @@ static int runCommand(int argc, const char **argv, DFError **dferr)
     else if ((argc == 3) && !strcmp(argv[1],"-normalize")) {
         return normalizeFile(argv[2],dferr);
     }
-    else if ((argc >= 3) && !strcmp(argv[1],"-test")) {
-        return runTests(argc-2,&argv[2],0,dferr);
-    }
-    else if ((argc >= 3) && !strcmp(argv[1],"-testdiff")) {
-        return runTests(argc-2,&argv[2],1,dferr);
-    }
     else if ((argc >= 2) && !strcmp(argv[1],"-bdt")) {
         BDT_Test(argc-2,&argv[2]);
         return 1;
@@ -121,12 +114,6 @@ static int runCommand(int argc, const char **argv, DFError **dferr)
               "dfutil -normalize filename\n"
               "    Normalize a HTML file\n"
               "\n"
-              "dfutil -test path1 path2 ...\n"
-              "    Run a series of automated tests, consisting of all the .test files in
the\n"
-              "    specified path(s). If only one file is found, the test is run and the\n"
-              "    result is printed to standard output. If multiple files are found, they
are\n"
-              "    all run, and their pass/fail status is printed.\n"
-              "\n"
               "dfutil -parsecontent string\n"
               "    Parse a value as if it were given as a CSS 'content' property, and print
parts\n"
               "\n"


Mime
View raw message