DEADSOFTWARE

Testing odcread against a bunch of existing .odc files
authorGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Sun, 13 Nov 2011 17:12:56 +0000 (17:12 +0000)
committerGert van Valkenhoef <g.h.m.van.valkenhoef@rug.nl>
Sun, 13 Nov 2011 17:12:56 +0000 (17:12 +0000)
odcread.cc
paths.txt [new file with mode: 0644]
test.sh [new file with mode: 0755]

index e790fdd36bcdc3b211d3c4d277cf9462ee6db3dd..858028e6babf5e252ede8ade0c0f71d2946ceb4e 100644 (file)
@@ -113,12 +113,27 @@ int main(int argc, char *argv[]) {
                return 1;
        }
        std::ifstream in(argv[1], std::ios::in | std::ios::binary);
-       odc::Store* s = odc::importDocument(in);
+
+       odc::Store* s;
+       try {
+               s = odc::importDocument(in);
+       } catch (int trap) {
+               std::cerr << "Exception in parsing file: BlackBox trap no. " << trap << std::endl;
+               return 2;
+       } catch (const char * exception) {
+               std::cerr << "Exception in parsing file: " << exception << std::endl;
+               return 2;
+       }
 //     std::cout << s->toPlainText() << std::endl;
 //     std::cout << std::endl << std::endl;
 
-       odc::MyVisitor visitor;
-       s->accept(visitor);
+       try {
+               odc::MyVisitor visitor;
+               s->accept(visitor);
+       } catch (const char * exception) {
+               std::cerr << "Exception in processing document: " << exception << std::endl;
+               return 3;
+       }
 //     std::cout << s->toString() << std::endl;
 //     std::cout << in.tellg() << " " << in.eof() << std::endl;
 
diff --git a/paths.txt b/paths.txt
new file mode 100644 (file)
index 0000000..baeb906
--- /dev/null
+++ b/paths.txt
@@ -0,0 +1,8 @@
+/home/gert/WINBUGS TSD2/
+/home/gert/Downloads/complex-interventsions/
+/home/gert/Downloads/jasa web/
+/home/gert/Downloads/bias-jrssa/
+/home/gert/Downloads/RBugsfiles/
+/home/gert/.wine/drive_c/Program Files/WinBUGS14/
+/home/gert/.wine/drive_c/Program Files/BlackBox Component Builder 1.5/
+/home/gert/.wine/drive_c/Program Files/OpenBUGS/OpenBUGS321/
diff --git a/test.sh b/test.sh
new file mode 100755 (executable)
index 0000000..022320b
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+SEP="================================================================================"
+
+runTests() {
+       echo "Output files to $outdir"
+       while read i; do
+               echo -e "$SEP\n$SEP"
+               echo "Running examples from " $i
+               (cd "$i"
+               find . -name '*.odc' | while read j; do
+                       echo $SEP
+                       echo "Running example $j from $i"
+                       out=${j/#\.\//}
+                       out=${out//\//_}
+                       echo "Output being sent to $out"
+                       out=$outdir/$out
+                       $odcread "$j" >"$out"
+               done
+               )
+               echo
+       done < 'paths.txt'
+}
+
+# create clean output directory
+rm -rf out
+mkdir out
+
+odcread=`readlink -f odcread`
+outdir=`readlink -f out`
+
+runTests 2>&1 | tee out.txt