changeset 228:56ff594b022c

Add tests for parse errors in invalid transform files
author Chris Cannam
date Thu, 25 Feb 2016 12:04:10 +0000
parents 88044af67bd1
children c58e123419fb
files tests/test-parse-errors/expected/empty.ttl.txt tests/test-parse-errors/expected/empty.xml.txt tests/test-parse-errors/expected/garbage.dat.txt tests/test-parse-errors/expected/invalid-turtle.ttl.txt tests/test-parse-errors/expected/invalid-xml.xml.txt tests/test-parse-errors/expected/valid-turtle-no-transform.ttl.txt tests/test-parse-errors/expected/valid-xml-no-transform.xml.txt tests/test-parse-errors/inputs/empty.ttl tests/test-parse-errors/inputs/empty.xml tests/test-parse-errors/inputs/garbage.dat tests/test-parse-errors/inputs/invalid-turtle.ttl tests/test-parse-errors/inputs/invalid-xml.xml tests/test-parse-errors/inputs/valid-turtle-no-transform.ttl tests/test-parse-errors/inputs/valid-xml-no-transform.xml tests/test-parse-errors/test-parse-errors.sh tests/test.sh
diffstat 14 files changed, 58 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/empty.ttl.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+RDF parser reported: Failed to import model from URL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/empty.xml.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+XML parser reported: unexpected end of file at line 1, column 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/garbage.dat.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,2 @@
+ERROR: RDF parser reported:
+ERROR: XML parser reported:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/invalid-turtle.ttl.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+RDF parser reported: Failed to import model from URL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/invalid-xml.xml.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+XML parser reported: tag mismatch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/valid-turtle-no-transform.ttl.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+valid RDF but defines no transforms
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/expected/valid-xml-no-transform.xml.txt	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+valid XML but defines no transform
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/inputs/garbage.dat	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+gZ~zN9Ԭb$7:2s𤇧0H2	zZ4#<An#|lTs:o_BKꥵ+-%WY[N-tLf7Ҷ
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/inputs/invalid-turtle.ttl	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,2 @@
+# Trailing ;
+<http://example/s> <http://example/p> <http://example/o> ;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/inputs/invalid-xml.xml	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0">
+  <channel>
+    <title>A Title</title>
+    <link>http://example.com</link>
+    <description/>
+    <!-- NB missing end-tag for channel -->
+</rss>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/inputs/valid-turtle-no-transform.ttl	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,1 @@
+<http://example/s> <http://example/p> <http://example/o> .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/inputs/valid-xml-no-transform.xml	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0">
+  <channel>
+    <title>A Title</title>
+    <link>http://example.com</link>
+    <description/>
+  </channel>
+</rss>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-parse-errors/test-parse-errors.sh	Thu Feb 25 12:04:10 2016 +0000
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+. ../include.sh
+
+infile=$audiopath/3clicks8.wav
+tmpfile=$mypath/tmp_$$
+trap "rm -f $tmpfile" 0
+
+for transform in "$mypath"/inputs/* ; do
+
+    base=$(basename "$transform")
+    expected="$mypath"/expected/"$base".txt
+
+    if [ ! -f "$expected" ]; then
+	fail "Internal error: Expected file $expected not found for transform $transform"
+    fi
+
+    if $r -t "$transform" -w csv --csv-one-file /dev/null "$infile" 2>"$tmpfile" ; then
+	fail "Erroneously succeeds in running bogus transform $transform"
+    fi
+
+    cat "$expected" | while read line; do
+	if ! fgrep -q "$line" "$tmpfile" ; then
+	    fail "Expected output text \"$line\" not found in diagnostic output for transform $base"
+	fi
+    done
+    
+done
+
--- a/tests/test.sh	Thu Feb 25 10:53:10 2016 +0000
+++ b/tests/test.sh	Thu Feb 25 12:04:10 2016 +0000
@@ -5,6 +5,7 @@
 for x in \
     supportprogs \
     helpfulflags \
+    parse-errors \
     transforms-basic \
     audioformat \
     vamp-test-plugin \