Mercurial > hg > sonic-annotator
comparison tests/test-json-destinations/test-json-destinations.sh @ 150:d86ef0a88fa4 jams
JSON destination tests
author | Chris Cannam |
---|---|
date | Tue, 14 Oct 2014 11:24:05 +0100 |
parents | tests/test-rdf-destinations/test-rdf-destinations.sh@1a6eab755c81 |
children | a1300db6c63e |
comparison
equal
deleted
inserted
replaced
149:56dcb5f67ed1 | 150:d86ef0a88fa4 |
---|---|
1 #!/bin/bash | |
2 | |
3 . ../include.sh | |
4 | |
5 infile1=$audiopath/3clicks8.wav | |
6 infile2=$audiopath/6clicks8.wav | |
7 | |
8 infile1dot=$audiopath/3.clicks.8.wav | |
9 | |
10 outfile1=3clicks8.json | |
11 outfile2=6clicks8.json | |
12 | |
13 outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.json | |
14 outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.json | |
15 outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.json | |
16 outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.json | |
17 | |
18 outfile1dot=3.clicks.8.json | |
19 | |
20 tmpjson=$mypath/tmp_1_$$.json | |
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 | |
23 | |
24 transformdir=$mypath/transforms | |
25 | |
26 check_json() { | |
27 test -f $1 || \ | |
28 fail "Fails to write output to expected location $1 for $2" | |
29 ##!!! todo! | |
30 rm -f $1 | |
31 } | |
32 | |
33 | |
34 ctx="onsets transform, one audio file, default JSON writer destination" | |
35 | |
36 rm -f $audiopath/$outfile1 | |
37 | |
38 $r -t $transformdir/onsets.n3 -w json $infile1 2>/dev/null || \ | |
39 fail "Fails to run with $ctx" | |
40 | |
41 check_json $audiopath/$outfile1 "$ctx" | |
42 | |
43 | |
44 ctx="onsets transform, one audio file with dots in filename, default JSON writer destination" | |
45 | |
46 rm -f $audiopath/$outfile1 | |
47 | |
48 cp $infile1 $infile1dot | |
49 | |
50 $r -t $transformdir/onsets.n3 -w json $infile1dot 2>/dev/null || \ | |
51 fail "Fails to run with $ctx" | |
52 | |
53 check_json $audiopath/$outfile1dot "$ctx" | |
54 | |
55 rm -f $infile1dot $audiopath/$outfile1dot | |
56 | |
57 | |
58 ctx="onsets and df transforms, one audio file, default JSON writer destination" | |
59 | |
60 rm -f $audiopath/$outfile1 | |
61 | |
62 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json $infile1 2>/dev/null || \ | |
63 fail "Fails to run with $ctx" | |
64 | |
65 check_json $audiopath/$outfile1 "$ctx" | |
66 | |
67 | |
68 ctx="onsets transform, two audio files, default JSON writer destination" | |
69 | |
70 rm -f $audiopath/$outfile1 | |
71 rm -f $audiopath/$outfile2 | |
72 | |
73 $r -t $transformdir/onsets.n3 -w json $infile1 $infile2 2>/dev/null || \ | |
74 fail "Fails to run with $ctx" | |
75 | |
76 check_json $audiopath/$outfile1 "$ctx" | |
77 check_json $audiopath/$outfile2 "$ctx" | |
78 | |
79 | |
80 ctx="onsets transform, two audio files, one-file JSON writer" | |
81 | |
82 # Does not support one file across all tracks | |
83 | |
84 $r -t $transformdir/onsets.n3 -w json --json-one-file $tmpjson $infile1 $infile2 2>/dev/null && \ | |
85 fail "Fails by completing successfully with $ctx" | |
86 | |
87 | |
88 ctx="onsets transform, two audio files, stdout JSON writer" | |
89 | |
90 $r -t $transformdir/onsets.n3 -w json --json-stdout $infile1 $infile2 2>/dev/null >$tmpjson || \ | |
91 fail "Fails to run with $ctx" | |
92 | |
93 check_json $tmpjson "$ctx" | |
94 | |
95 | |
96 ctx="onsets transform, one audio file, many-files JSON writer" | |
97 | |
98 rm -f $audiopath/$outfile3 | |
99 | |
100 $r -t $transformdir/onsets.n3 -w json --json-many-files $infile1 2>/dev/null || \ | |
101 fail "Fails to run with $ctx" | |
102 | |
103 check_json $audiopath/$outfile3 "$ctx" | |
104 | |
105 | |
106 ctx="onsets transform, two audio files, many-files JSON writer" | |
107 | |
108 rm -f $audiopath/$outfile3 | |
109 rm -f $audiopath/$outfile5 | |
110 | |
111 $r -t $transformdir/onsets.n3 -w json --json-many-files $infile1 $infile2 2>/dev/null || \ | |
112 fail "Fails to run with $ctx" | |
113 | |
114 check_json $audiopath/$outfile3 "$ctx" | |
115 check_json $audiopath/$outfile5 "$ctx" | |
116 | |
117 | |
118 ctx="onsets and df transforms, two audio files, many-files JSON writer" | |
119 | |
120 rm -f $audiopath/$outfile3 | |
121 rm -f $audiopath/$outfile4 | |
122 rm -f $audiopath/$outfile5 | |
123 rm -f $audiopath/$outfile6 | |
124 | |
125 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json --json-many-files $infile1 $infile2 2>/dev/null || \ | |
126 fail "Fails to run with $ctx" | |
127 | |
128 check_json $audiopath/$outfile3 "$ctx" | |
129 check_json $audiopath/$outfile4 "$ctx" | |
130 check_json $audiopath/$outfile5 "$ctx" | |
131 check_json $audiopath/$outfile6 "$ctx" | |
132 | |
133 | |
134 ctx="output base directory" | |
135 | |
136 rm -f ./$outfile1 | |
137 | |
138 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w json --json-basedir . $infile1 2>/dev/null || \ | |
139 fail "Fails to run with $ctx" | |
140 | |
141 check_json ./$outfile1 "$ctx" | |
142 | |
143 | |
144 ctx="output base directory and many-files" | |
145 | |
146 rm -f ./$outfile3 | |
147 rm -f ./$outfile5 | |
148 | |
149 $r -t $transformdir/onsets.n3 -w json --json-basedir . --json-many-files $infile1 $infile2 2>/dev/null || \ | |
150 fail "Fails to run with $ctx" | |
151 | |
152 check_json ./$outfile3 "$ctx" | |
153 check_json ./$outfile5 "$ctx" | |
154 | |
155 | |
156 ctx="nonexistent output base directory" | |
157 | |
158 $r -t $transformdir/onsets.n3 -w json --json-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \ | |
159 fail "Fails with $ctx by completing successfully (should refuse and bail out)" | |
160 | |
161 | |
162 ctx="existing output file and no --json-force" | |
163 | |
164 touch $audiopath/$outfile1 | |
165 | |
166 $r -t $transformdir/onsets.n3 -w json $infile1 2>/dev/null && \ | |
167 fail "Fails by completing successfully when output file already exists (should refuse and bail out)" | |
168 | |
169 | |
170 ctx="existing output file and --json-force" | |
171 | |
172 touch $audiopath/$outfile1 | |
173 | |
174 $r -t $transformdir/onsets.n3 -w json --json-force $infile1 2>/dev/null || \ | |
175 fail "Fails to run with $ctx" | |
176 | |
177 check_json $audiopath/$outfile1 "$ctx" | |
178 | |
179 | |
180 exit 0 |