diff tests/include.sh @ 119:7a31201dc42d test-reorg

Split out tests into individual directories, with simpler naming therein
author Chris Cannam
date Wed, 08 Oct 2014 15:08:57 +0100
parents tests/test-include.sh@0fe5abb56a6e
children e6379b2e1c5c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/include.sh	Wed Oct 08 15:08:57 2014 +0100
@@ -0,0 +1,54 @@
+
+mypath=`dirname $0`
+
+testdir=$mypath/..
+r=$testdir/../sonic-annotator
+
+audiopath=$testdir/audio
+
+percplug=vamp:vamp-example-plugins:percussiononsets
+testplug=vamp:vamp-test-plugin:vamp-test-plugin
+
+fail() {
+    echo "Test failed: $1"
+    exit 1
+}
+
+csvcompare() {
+    # permit some fuzz in final few digits
+    a="$1"
+    b="$2"
+    perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$a" > "${a}__"
+    perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$b" > "${b}__"
+    cmp -s "${a}__" "${b}__"
+    rv=$?
+    rm "${a}__" "${b}__"
+    return $rv
+}
+
+csvcompare_ignorefirst() {
+    # a bit like the above, but ignoring first column (and without temp files)
+    out=`cat "$1" "$2" | cut -d, -f2- | perl -p -e 's/(\d+\.\d{6})\d+/$1/' | sort | uniq -c | grep -v ' 2 '`
+    return `[ -z "$out" ]`
+}
+
+faildiff() {
+    echo "Test failed: $1"
+    if [ -n "$2" -a -n "$3" ]; then
+	echo "Output follows:"
+	echo "--"
+	cat $2
+	echo "--"
+	echo "Expected output follows:"
+	echo "--"
+	cat $3
+	echo "--"
+	echo "Diff:"
+	echo "--"
+	sdiff -w78 $2 $3
+	echo "--"
+    fi
+    exit 1
+}
+
+