comparison tests/include.sh @ 288:fd4a6183482f kapoor_1202

Merge from branch piper-nopiper. The next release will be based on this.
author Chris Cannam
date Fri, 02 Dec 2016 10:04:44 +0000
parents bd6e98b348cf
children aca11ce8a637
comparison
equal deleted inserted replaced
259:9e7d180be225 288:fd4a6183482f
11 exit 1;; 11 exit 1;;
12 *) 12 *)
13 ;; 13 ;;
14 esac 14 esac
15 15
16 version=1.5 16 version=1.5pre
17 nextversion=1.6 17 nextversion=1.6
18 18
19 testdir=$mypath/.. 19 testdir=$mypath/..
20 r=$testdir/../sonic-annotator 20 r=$testdir/../sonic-annotator
21 21
62 jsoncompare() { 62 jsoncompare() {
63 # The Sonic Annotator version number appears in the JAMS output -- 63 # The Sonic Annotator version number appears in the JAMS output --
64 # filter that out, and also reformat to ignore whitespace differences 64 # filter that out, and also reformat to ignore whitespace differences
65 a="$1" 65 a="$1"
66 b="$2" 66 b="$2"
67 cat "$a" | sed 's/Sonic Annotator v[0-9.]*/Sonic Annotator vXXX/' | json_reformat > "${a}__" 67 cat "$a" | sed 's/Sonic Annotator v[0-9a-z.]*/Sonic Annotator vXXX/' | json_reformat > "${a}__"
68 cat "$b" | sed 's/Sonic Annotator v[0-9.]*/Sonic Annotator vXXX/' | json_reformat > "${b}__" 68 cat "$b" | sed 's/Sonic Annotator v[0-9a-z.]*/Sonic Annotator vXXX/' | json_reformat > "${b}__"
69 cmp -s "${a}__" "${b}__" 69 cmp -s "${a}__" "${b}__"
70 rv=$? 70 rv=$?
71 rm "${a}__" "${b}__" 71 rm "${a}__" "${b}__"
72 return $rv 72 return $rv
73 } 73 }
74
75 SDIFF_WIDTH=140
74 76
75 faildiff() { 77 faildiff() {
76 echo "Test failed: $1" 78 echo "Test failed: $1"
77 if [ -n "$2" -a -n "$3" ]; then 79 if [ -n "$2" -a -n "$3" ]; then
78 echo "Output follows:" 80 echo "Output follows:"
79 echo "--" 81 echo "--"
80 cat "$2" 82 cat "$2"
81 echo "--" 83 echo "--"
82 echo "Expected output follows:" 84 echo "Expected output follows ($3):"
83 echo "--" 85 echo "--"
84 cat "$3" 86 cat "$3"
85 echo "--" 87 echo "--"
86 echo "Diff (output on left, expected on right):" 88 echo "Diff (output on left, expected on right):"
87 echo "--" 89 echo "--"
88 sdiff -w78 "$2" "$3" 90 sdiff -w${SDIFF_WIDTH} "$2" "$3"
89 echo "--" 91 echo "--"
90 fi 92 fi
91 exit 1 93 exit 1
92 } 94 }
93 95
96 if [ -n "$2" -a -n "$3" ]; then 98 if [ -n "$2" -a -n "$3" ]; then
97 echo "Output follows:" 99 echo "Output follows:"
98 echo "--" 100 echo "--"
99 od -c "$2" 101 od -c "$2"
100 echo "--" 102 echo "--"
101 echo "Expected output follows:" 103 echo "Expected output follows ($3):"
102 echo "--" 104 echo "--"
103 od -c "$3" 105 od -c "$3"
104 echo "--" 106 echo "--"
105 echo "Diff:" 107 echo "Diff:"
106 echo "--" 108 echo "--"
107 od -w8 -c "$3" > "${3}__" 109 od -w8 -c "$3" > "${3}__"
108 od -w8 -c "$2" | sdiff -w78 - "${3}__" 110 od -w8 -c "$2" | sdiff -w${SDIFF_WIDTH} - "${3}__"
109 rm "${3}__" 111 rm "${3}__"
110 echo "--" 112 echo "--"
111 fi 113 fi
112 exit 1 114 exit 1
113 } 115 }