Mercurial > hg > sonic-annotator
annotate tests/test-include.sh @ 116:1c0799754670
Normalise option (yet to be tested)
author | Chris Cannam |
---|---|
date | Fri, 03 Oct 2014 15:42:55 +0100 |
parents | 8b4924a9a072 |
children | 0fe5abb56a6e |
rev | line source |
---|---|
Chris@30 | 1 |
Chris@30 | 2 fail() { |
Chris@30 | 3 echo "Test failed: $1" |
Chris@30 | 4 exit 1 |
Chris@30 | 5 } |
Chris@30 | 6 |
Chris@30 | 7 csvcompare() { |
Chris@30 | 8 # permit some fuzz in final few digits |
Chris@30 | 9 a="$1" |
Chris@30 | 10 b="$2" |
Chris@30 | 11 perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$a" > "${a}__" |
Chris@30 | 12 perl -p -e 's/(\d+\.\d{6})\d+/$1/' "$b" > "${b}__" |
Chris@30 | 13 cmp -s "${a}__" "${b}__" |
Chris@30 | 14 rv=$? |
Chris@30 | 15 rm "${a}__" "${b}__" |
Chris@30 | 16 return $rv |
Chris@30 | 17 } |
Chris@30 | 18 |
Chris@75 | 19 csvcompare_ignorefirst() { |
Chris@75 | 20 # a bit like the above, but ignoring first column (and without temp files) |
Chris@75 | 21 out=`cat "$1" "$2" | cut -d, -f2- | perl -p -e 's/(\d+\.\d{6})\d+/$1/' | sort | uniq -c | grep -v ' 2 '` |
Chris@75 | 22 return `[ -z "$out" ]` |
Chris@75 | 23 } |
Chris@75 | 24 |
Chris@108 | 25 faildiff() { |
Chris@108 | 26 echo "Test failed: $1" |
Chris@108 | 27 if [ -n "$2" -a -n "$3" ]; then |
Chris@108 | 28 echo "Output follows:" |
Chris@108 | 29 echo "--" |
Chris@108 | 30 cat $2 |
Chris@108 | 31 echo "--" |
Chris@108 | 32 echo "Expected output follows:" |
Chris@108 | 33 echo "--" |
Chris@108 | 34 cat $3 |
Chris@108 | 35 echo "--" |
Chris@108 | 36 echo "Diff:" |
Chris@108 | 37 echo "--" |
Chris@108 | 38 sdiff -w78 $2 $3 |
Chris@108 | 39 echo "--" |
Chris@108 | 40 fi |
Chris@108 | 41 exit 1 |
Chris@108 | 42 } |
Chris@75 | 43 |
Chris@108 | 44 |