changeset 191:4ef452f5fefc

Add (failing) test for JSON output format (fails for grid output)
author Chris Cannam
date Wed, 22 Jul 2015 14:25:14 +0100
parents 2d2253469ca4
children bb295c0feb3e
files tests/include.sh tests/test-json-destinations/test-json-destinations.sh tests/test-json-writer/test-json-writer.sh tests/test-rdf-writer/test-rdf-writer.sh tests/test.sh
diffstat 5 files changed, 68 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/tests/include.sh	Mon Mar 02 17:21:59 2015 +0000
+++ b/tests/include.sh	Wed Jul 22 14:25:14 2015 +0100
@@ -67,4 +67,23 @@
     exit 1
 }
 
+failshow() {
+    echo "Test failed: $1"
+    if [ -n "$2" ]; then
+	echo "Output follows:"
+	echo "--"
+	cat $2
+	echo "--"
+    fi
+    exit 1
+}	
 
+check_json() {
+    test -f $1 || \
+	fail "Fails to write output to expected location $1 for $2"
+    cat $1 | json_verify -q || \
+	failshow "Writes invalid JSON to location $1 for $2" $1
+    rm -f $1
+}    
+
+
--- a/tests/test-json-destinations/test-json-destinations.sh	Mon Mar 02 17:21:59 2015 +0000
+++ b/tests/test-json-destinations/test-json-destinations.sh	Wed Jul 22 14:25:14 2015 +0100
@@ -23,25 +23,6 @@
 
 transformdir=$mypath/transforms
 
-failshow() {
-    echo "Test failed: $1"
-    if [ -n "$2" ]; then
-	echo "Output follows:"
-	echo "--"
-	cat $2
-	echo "--"
-    fi
-    exit 1
-}	
-
-check_json() {
-    test -f $1 || \
-	fail "Fails to write output to expected location $1 for $2"
-    cat $1 | json_verify -q || \
-	failshow "Writes invalid JSON to location $1 for $2" $1
-    rm -f $1
-}    
-
 
 ctx="onsets transform, one audio file, default JSON writer destination"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-json-writer/test-json-writer.sh	Wed Jul 22 14:25:14 2015 +0100
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+. ../include.sh
+
+tmpjson=$mypath/tmp_1_$$.json
+
+silentfile=$audiopath/20sec-silence.wav
+
+trap "rm -f $tmpjson" 0
+
+transformdir=$mypath/transforms
+
+# This does not yet test for correct values, only for parseable json
+
+for output in instants curve-oss curve-fsr curve-fsr-timed curve-vsr grid-oss grid-fsr notes-regions; do
+
+    $r -d "$testplug:$output" -w json --json-one-file "$tmpjson" --json-force "$silentfile" 2>/dev/null || \
+	fail "Failed to run for plugin $testplug with output $output"
+
+    check_json "$tmpjson" "test plugin output $output"
+done
+
--- a/tests/test-rdf-writer/test-rdf-writer.sh	Mon Mar 02 17:21:59 2015 +0000
+++ b/tests/test-rdf-writer/test-rdf-writer.sh	Wed Jul 22 14:25:14 2015 +0100
@@ -5,6 +5,8 @@
 infile=$audiopath/3clicks8.wav
 tmpttl=$mypath/tmp_1_$$.ttl
 
+silentfile=$audiopath/20sec-silence.wav
+
 trap "rm -f $tmpttl" 0
 
 transformdir=$mypath/transforms
@@ -14,39 +16,51 @@
     note=""
     [ -n "$rdfarg" ] && note=" with $rdfarg"
 
-    rm -f $tmpttl
+    rm -f "$tmpttl"
 
-    $r -t $transformdir/onsets.n3 -w rdf $infile $rdfarg --rdf-one-file $tmpttl 2>/dev/null || \
+    $r -t $transformdir/onsets.n3 -w rdf $infile $rdfarg --rdf-one-file "$tmpttl" 2>/dev/null || \
 	fail "Fails to run with onsets transform and RDF writer$note"
 
-    rapper -i turtle $tmpttl >/dev/null 2>&1 || \
+    rapper -i turtle "$tmpttl" >/dev/null 2>&1 || \
 	fail "Fails to produce parseable RDF/TTL for onsets transform$note"
 
-    rapper -i turtle -c $tmpttl 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
+    rapper -i turtle -c "$tmpttl" 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
 	fail "RDF output contains no triples (?) for onsets transform$note"
 
-    rm -f $tmpttl
+    rm -f "$tmpttl"
     
-    $r -t $transformdir/detectionfunction.n3 -w rdf $infile $rdfarg --rdf-one-file $tmpttl 2>/dev/null || \
+    $r -t $transformdir/detectionfunction.n3 -w rdf $infile $rdfarg --rdf-one-file "$tmpttl" 2>/dev/null || \
 	fail "Fails to run with detectionfunction transform and RDF writer$note"
 
-    rapper -i turtle $tmpttl >/dev/null 2>&1 || \
+    rapper -i turtle "$tmpttl" >/dev/null 2>&1 || \
 	fail "Fails to produce parseable RDF/TTL for detectionfunction transform$note"
 
-    rapper -i turtle -c $tmpttl 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
+    rapper -i turtle -c "$tmpttl" 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
 	fail "RDF output contains no triples (?) for detectionfunction transform$note"
 
-    rm -f $tmpttl
+    rm -f "$tmpttl"
 
-    $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w rdf $infile $rdfarg --rdf-one-file $tmpttl 2>/dev/null || \
+    $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w rdf $infile $rdfarg --rdf-one-file "$tmpttl" 2>/dev/null || \
 	fail "Fails to run with detectionfunction and onsets transforms together and RDF writer$note"
 
-    rapper -i turtle $tmpttl >/dev/null 2>&1 || \
+    rapper -i turtle "$tmpttl" >/dev/null 2>&1 || \
 	fail "Fails to produce parseable RDF/TTL for detectionfunction and onsets transforms together$note"
 
-    rapper -i turtle -c $tmpttl 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
+    rapper -i turtle -c "$tmpttl" 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
 	fail "RDF output contains no triples (?) for detectionfunction and onsets transforms together$note"
 
+    # And the various structures emitted by the Vamp test plugin
+    for output in instants curve-oss curve-fsr curve-fsr-timed curve-vsr grid-oss grid-fsr notes-regions; do
+
+	$r -d "$testplug:$output" -w rdf --rdf-one-file "$tmpttl" --rdf-force "$silentfile" 2>/dev/null || \
+	fail "Failed to run for plugin $testplug with output $output"
+
+	rapper -i turtle "$tmpttl" >/dev/null 2>&1 || \
+	    fail "Fails to produce parseable RDF/TTL for test plugin output $output"
+
+	rapper -i turtle -c "$tmpttl" 2>&1 | egrep -q 'Parsing returned [1-9][0-9]+ triples' ||
+	    fail "RDF output contains no triples (?) for test plugin output $output"
+    done
 done
 
 # Check the output encoding -- should be valid UTF-8 always
--- a/tests/test.sh	Mon Mar 02 17:21:59 2015 +0000
+++ b/tests/test.sh	Wed Jul 22 14:25:14 2015 +0100
@@ -17,6 +17,7 @@
     lab-destinations \
     midi-destinations \
     json-destinations \
+    json-writer \
     summaries \
     multiple-audio \
     ; do