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