annotate tests/include.sh @ 185:3287df4588dd

Warn for this potential error case
author Chris Cannam
date Fri, 20 Feb 2015 18:09:12 +0000
parents 11a9ce2fa331
children 4ef452f5fefc
rev   line source
Chris@118 1
Chris@182 2 set -e
Chris@119 3
Chris@182 4 mypath=$(dirname $0)
Chris@182 5
Chris@182 6 case "$(pwd)/$mypath" in
Chris@182 7 *" "*)
Chris@182 8 echo 1>&2
Chris@182 9 echo "ERROR: Test scripts do not handle paths containing spaces (yes, I know)" 1>&2
Chris@182 10 echo "(Path is: \"$(pwd)/$mypath\")" 1>&2
Chris@182 11 exit 1;;
Chris@182 12 *)
Chris@182 13 ;;
Chris@182 14 esac
Chris@182 15
Chris@182 16 version=1.2
Chris@182 17 nextversion=1.3
Chris@138 18
Chris@119 19 testdir=$mypath/..
Chris@119 20 r=$testdir/../sonic-annotator
Chris@119 21
Chris@119 22 audiopath=$testdir/audio
Chris@118 23
Chris@118 24 percplug=vamp:vamp-example-plugins:percussiononsets
Chris@126 25 amplplug=vamp:vamp-example-plugins:amplitudefollower
Chris@118 26 testplug=vamp:vamp-test-plugin:vamp-test-plugin
Chris@30 27
Chris@30 28 fail() {
Chris@30 29 echo "Test failed: $1"
Chris@30 30 exit 1
Chris@30 31 }
Chris@30 32
Chris@30 33 csvcompare() {
Chris@30 34 # permit some fuzz in final few digits
Chris@30 35 a="$1"
Chris@30 36 b="$2"
Chris@30 37 perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$a" > "${a}__"
Chris@30 38 perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$b" > "${b}__"
Chris@30 39 cmp -s "${a}__" "${b}__"
Chris@30 40 rv=$?
Chris@30 41 rm "${a}__" "${b}__"
Chris@30 42 return $rv
Chris@30 43 }
Chris@30 44
Chris@75 45 csvcompare_ignorefirst() {
Chris@75 46 # a bit like the above, but ignoring first column (and without temp files)
Chris@75 47 out=`cat "$1" "$2" | cut -d, -f2- | perl -p -e 's/(\d+\.\d{6})\d+/$1/' | sort | uniq -c | grep -v ' 2 '`
Chris@75 48 return `[ -z "$out" ]`
Chris@75 49 }
Chris@75 50
Chris@108 51 faildiff() {
Chris@108 52 echo "Test failed: $1"
Chris@108 53 if [ -n "$2" -a -n "$3" ]; then
Chris@108 54 echo "Output follows:"
Chris@108 55 echo "--"
Chris@108 56 cat $2
Chris@108 57 echo "--"
Chris@108 58 echo "Expected output follows:"
Chris@108 59 echo "--"
Chris@108 60 cat $3
Chris@108 61 echo "--"
Chris@108 62 echo "Diff:"
Chris@108 63 echo "--"
Chris@108 64 sdiff -w78 $2 $3
Chris@108 65 echo "--"
Chris@108 66 fi
Chris@108 67 exit 1
Chris@108 68 }
Chris@75 69
Chris@108 70