comparison tests/test-json-destinations/test-json-destinations.sh @ 197:3b7ec45abd1c

Add mandatory option --json-format to JSON feature writer, in preparation for supporting multiple JSON formats (perhaps) in future
author Chris Cannam
date Tue, 01 Sep 2015 17:05:32 +0100
parents 4ef452f5fefc
children
comparison
equal deleted inserted replaced
196:082c3f21f49e 197:3b7ec45abd1c
21 21
22 trap "rm -f $tmpjson $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0 22 trap "rm -f $tmpjson $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0
23 23
24 transformdir=$mypath/transforms 24 transformdir=$mypath/transforms
25 25
26 mandatory="-w json --json-format jams"
27
26 28
27 ctx="onsets transform, one audio file, default JSON writer destination" 29 ctx="onsets transform, one audio file, default JSON writer destination"
28 30
29 rm -f $audiopath/$outfile1 31 rm -f $audiopath/$outfile1
30 32
31 $r -t $transformdir/onsets.n3 -w json $infile1 2>/dev/null || \ 33 $r -t $transformdir/onsets.n3 $mandatory $infile1 2>/dev/null || \
32 fail "Fails to run with $ctx" 34 fail "Fails to run with $ctx"
33 35
34 check_json $audiopath/$outfile1 "$ctx" 36 check_json $audiopath/$outfile1 "$ctx"
35 37
36 38
38 40
39 rm -f $audiopath/$outfile1 41 rm -f $audiopath/$outfile1
40 42
41 cp $infile1 $infile1dot 43 cp $infile1 $infile1dot
42 44
43 $r -t $transformdir/onsets.n3 -w json $infile1dot 2>/dev/null || \ 45 $r -t $transformdir/onsets.n3 $mandatory $infile1dot 2>/dev/null || \
44 fail "Fails to run with $ctx" 46 fail "Fails to run with $ctx"
45 47
46 check_json $audiopath/$outfile1dot "$ctx" 48 check_json $audiopath/$outfile1dot "$ctx"
47 49
48 rm -f $infile1dot $audiopath/$outfile1dot 50 rm -f $infile1dot $audiopath/$outfile1dot
50 52
51 ctx="onsets and df transforms, one audio file, default JSON writer destination" 53 ctx="onsets and df transforms, one audio file, default JSON writer destination"
52 54
53 rm -f $audiopath/$outfile1 55 rm -f $audiopath/$outfile1
54 56
55 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json $infile1 2>/dev/null || \ 57 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 $mandatory $infile1 2>/dev/null || \
56 fail "Fails to run with $ctx" 58 fail "Fails to run with $ctx"
57 59
58 check_json $audiopath/$outfile1 "$ctx" 60 check_json $audiopath/$outfile1 "$ctx"
59 61
60 62
61 ctx="onsets transform, two audio files, default JSON writer destination" 63 ctx="onsets transform, two audio files, default JSON writer destination"
62 64
63 rm -f $audiopath/$outfile1 65 rm -f $audiopath/$outfile1
64 rm -f $audiopath/$outfile2 66 rm -f $audiopath/$outfile2
65 67
66 $r -t $transformdir/onsets.n3 -w json $infile1 $infile2 2>/dev/null || \ 68 $r -t $transformdir/onsets.n3 $mandatory $infile1 $infile2 2>/dev/null || \
67 fail "Fails to run with $ctx" 69 fail "Fails to run with $ctx"
68 70
69 check_json $audiopath/$outfile1 "$ctx" 71 check_json $audiopath/$outfile1 "$ctx"
70 check_json $audiopath/$outfile2 "$ctx" 72 check_json $audiopath/$outfile2 "$ctx"
71 73
72 74
73 ctx="onsets transform, two audio files, one-file JSON writer" 75 ctx="onsets transform, two audio files, one-file JSON writer"
74 76
75 $r -t $transformdir/onsets.n3 -w json --json-one-file $tmpjson $infile1 $infile2 2>/dev/null || \ 77 $r -t $transformdir/onsets.n3 $mandatory --json-one-file $tmpjson $infile1 $infile2 2>/dev/null || \
76 fail "Fails to run with $ctx" 78 fail "Fails to run with $ctx"
77 79
78 check_json $tmpjson "$ctx" 80 check_json $tmpjson "$ctx"
79 81
80 82
81 ctx="onsets transform, two audio files, stdout JSON writer" 83 ctx="onsets transform, two audio files, stdout JSON writer"
82 84
83 $r -t $transformdir/onsets.n3 -w json --json-stdout $infile1 $infile2 2>/dev/null >$tmpjson || \ 85 $r -t $transformdir/onsets.n3 $mandatory --json-stdout $infile1 $infile2 2>/dev/null >$tmpjson || \
84 fail "Fails to run with $ctx" 86 fail "Fails to run with $ctx"
85 87
86 check_json $tmpjson "$ctx" 88 check_json $tmpjson "$ctx"
87 89
88 90
89 ctx="onsets transform, one audio file, many-files JSON writer" 91 ctx="onsets transform, one audio file, many-files JSON writer"
90 92
91 rm -f $audiopath/$outfile3 93 rm -f $audiopath/$outfile3
92 94
93 $r -t $transformdir/onsets.n3 -w json --json-many-files $infile1 2>/dev/null || \ 95 $r -t $transformdir/onsets.n3 $mandatory --json-many-files $infile1 2>/dev/null || \
94 fail "Fails to run with $ctx" 96 fail "Fails to run with $ctx"
95 97
96 check_json $audiopath/$outfile3 "$ctx" 98 check_json $audiopath/$outfile3 "$ctx"
97 99
98 100
99 ctx="onsets transform, two audio files, many-files JSON writer" 101 ctx="onsets transform, two audio files, many-files JSON writer"
100 102
101 rm -f $audiopath/$outfile3 103 rm -f $audiopath/$outfile3
102 rm -f $audiopath/$outfile5 104 rm -f $audiopath/$outfile5
103 105
104 $r -t $transformdir/onsets.n3 -w json --json-many-files $infile1 $infile2 2>/dev/null || \ 106 $r -t $transformdir/onsets.n3 $mandatory --json-many-files $infile1 $infile2 2>/dev/null || \
105 fail "Fails to run with $ctx" 107 fail "Fails to run with $ctx"
106 108
107 check_json $audiopath/$outfile3 "$ctx" 109 check_json $audiopath/$outfile3 "$ctx"
108 check_json $audiopath/$outfile5 "$ctx" 110 check_json $audiopath/$outfile5 "$ctx"
109 111
113 rm -f $audiopath/$outfile3 115 rm -f $audiopath/$outfile3
114 rm -f $audiopath/$outfile4 116 rm -f $audiopath/$outfile4
115 rm -f $audiopath/$outfile5 117 rm -f $audiopath/$outfile5
116 rm -f $audiopath/$outfile6 118 rm -f $audiopath/$outfile6
117 119
118 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json --json-many-files $infile1 $infile2 2>/dev/null || \ 120 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 $mandatory --json-many-files $infile1 $infile2 2>/dev/null || \
119 fail "Fails to run with $ctx" 121 fail "Fails to run with $ctx"
120 122
121 check_json $audiopath/$outfile3 "$ctx" 123 check_json $audiopath/$outfile3 "$ctx"
122 check_json $audiopath/$outfile4 "$ctx" 124 check_json $audiopath/$outfile4 "$ctx"
123 check_json $audiopath/$outfile5 "$ctx" 125 check_json $audiopath/$outfile5 "$ctx"
126 128
127 ctx="output base directory" 129 ctx="output base directory"
128 130
129 rm -f ./$outfile1 131 rm -f ./$outfile1
130 132
131 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json --json-basedir . $infile1 2>/dev/null || \ 133 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 $mandatory --json-basedir . $infile1 2>/dev/null || \
132 fail "Fails to run with $ctx" 134 fail "Fails to run with $ctx"
133 135
134 check_json ./$outfile1 "$ctx" 136 check_json ./$outfile1 "$ctx"
135 137
136 138
137 ctx="output base directory and many-files" 139 ctx="output base directory and many-files"
138 140
139 rm -f ./$outfile3 141 rm -f ./$outfile3
140 rm -f ./$outfile5 142 rm -f ./$outfile5
141 143
142 $r -t $transformdir/onsets.n3 -w json --json-basedir . --json-many-files $infile1 $infile2 2>/dev/null || \ 144 $r -t $transformdir/onsets.n3 $mandatory --json-basedir . --json-many-files $infile1 $infile2 2>/dev/null || \
143 fail "Fails to run with $ctx" 145 fail "Fails to run with $ctx"
144 146
145 check_json ./$outfile3 "$ctx" 147 check_json ./$outfile3 "$ctx"
146 check_json ./$outfile5 "$ctx" 148 check_json ./$outfile5 "$ctx"
147 149
148 150
149 ctx="nonexistent output base directory" 151 ctx="nonexistent output base directory"
150 152
151 $r -t $transformdir/onsets.n3 -w json --json-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \ 153 $r -t $transformdir/onsets.n3 $mandatory --json-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \
152 fail "Fails with $ctx by completing successfully (should refuse and bail out)" 154 fail "Fails with $ctx by completing successfully (should refuse and bail out)"
153 155
154 156
155 ctx="existing output file and no --json-force" 157 ctx="existing output file and no --json-force"
156 158
157 touch $audiopath/$outfile1 159 touch $audiopath/$outfile1
158 160
159 $r -t $transformdir/onsets.n3 -w json $infile1 2>/dev/null && \ 161 $r -t $transformdir/onsets.n3 $mandatory $infile1 2>/dev/null && \
160 fail "Fails by completing successfully when output file already exists (should refuse and bail out)" 162 fail "Fails by completing successfully when output file already exists (should refuse and bail out)"
161 163
162 164
163 ctx="existing output file and --json-force" 165 ctx="existing output file and --json-force"
164 166
165 touch $audiopath/$outfile1 167 touch $audiopath/$outfile1
166 168
167 $r -t $transformdir/onsets.n3 -w json --json-force $infile1 2>/dev/null || \ 169 $r -t $transformdir/onsets.n3 $mandatory --json-force $infile1 2>/dev/null || \
168 fail "Fails to run with $ctx" 170 fail "Fails to run with $ctx"
169 171
170 check_json $audiopath/$outfile1 "$ctx" 172 check_json $audiopath/$outfile1 "$ctx"
171 173
172 174