Mercurial > hg > sonic-annotator
changeset 228:56ff594b022c
Add tests for parse errors in invalid transform files
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 +