Mercurial > hg > sonic-visualiser
annotate export-tests/test-scripted-generation.sh @ 2596:04d381f0d89a tip
Default branch is now named default on git as well as hg, in case we ever want to switch to mirroring in the other direction
author | Chris Cannam |
---|---|
date | Thu, 27 Aug 2020 15:58:56 +0100 (2020-08-27) |
parents | 0cbdd15a96f4 |
children |
rev | line source |
---|---|
Chris@2574 | 1 #!/bin/bash |
Chris@2574 | 2 |
Chris@2574 | 3 set -e |
Chris@2574 | 4 |
Chris@2574 | 5 if [ -n "$1" ]; then |
Chris@2574 | 6 echo "Usage: $0" 1>&2 |
Chris@2574 | 7 exit 2 |
Chris@2574 | 8 fi |
Chris@2574 | 9 |
Chris@2574 | 10 set -u |
Chris@2574 | 11 |
Chris@2574 | 12 sv="../sonic-visualiser" |
Chris@2574 | 13 if [ ! -f "$sv" -o ! -x "$sv" ]; then |
Chris@2574 | 14 echo "This script must be run from the sonic-visualiser/test directory" 1>&2 |
Chris@2574 | 15 exit 1 |
Chris@2574 | 16 fi |
Chris@2574 | 17 |
Chris@2574 | 18 version=$("$sv" -v 2>&1 | grep -v App) |
Chris@2574 | 19 adequate=no |
Chris@2574 | 20 case "$version" in |
Chris@2574 | 21 [0123].*) ;; |
Chris@2574 | 22 4.0*) ;; |
Chris@2574 | 23 [1-9]*) adequate=yes ;; |
Chris@2574 | 24 *) echo "Failed to query Sonic Visualiser version" 1>&2 |
Chris@2574 | 25 exit 1 ;; |
Chris@2574 | 26 esac |
Chris@2574 | 27 if [ "$adequate" = "no" ]; then |
Chris@2574 | 28 echo "Sonic Visualiser version must be at least 4.1 (supporting --osc-script option with standard input)" 1>&2 |
Chris@2574 | 29 exit 1 |
Chris@2574 | 30 fi |
Chris@2574 | 31 |
Chris@2574 | 32 tmpdir=$(mktemp -d) |
Chris@2574 | 33 trap "rm -rf $tmpdir" 0 |
Chris@2574 | 34 |
Chris@2574 | 35 for method in 1 2; do |
Chris@2574 | 36 |
Chris@2574 | 37 echo "Testing method $method..." |
Chris@2574 | 38 |
Chris@2574 | 39 actual="$tmpdir/3dplot.csv" |
Chris@2574 | 40 expected="layers-expected/3dplot.csv" |
Chris@2574 | 41 |
Chris@2574 | 42 rm -f "$actual" |
Chris@2574 | 43 |
Chris@2574 | 44 if [ "$method" = "1" ]; then |
Chris@2574 | 45 ( echo "/open s1.wav" ; |
Chris@2574 | 46 echo "/transform vamp:qm-vamp-plugins:qm-keydetector:keystrength" ; |
Chris@2574 | 47 echo "/exportlayer $actual" ; |
Chris@2574 | 48 echo "/quit" ) | |
Chris@2574 | 49 ../sonic-visualiser --osc-script - |
Chris@2574 | 50 else |
Chris@2574 | 51 ( echo "/transform vamp:qm-vamp-plugins:qm-keydetector:keystrength" ; |
Chris@2574 | 52 echo "/exportlayer $actual" ; |
Chris@2574 | 53 echo "/quit" ) | |
Chris@2574 | 54 ../sonic-visualiser --osc-script - s1.wav |
Chris@2574 | 55 fi |
Chris@2574 | 56 |
Chris@2574 | 57 if ! cmp -s "$actual" "$expected" ; then |
Chris@2574 | 58 echo |
Chris@2574 | 59 echo "Test failed for method $method" |
Chris@2574 | 60 echo |
Chris@2574 | 61 echo "Actual:" |
Chris@2574 | 62 ls -l "$actual" |
Chris@2574 | 63 echo "Expected:" |
Chris@2574 | 64 ls -l "$expected" |
Chris@2574 | 65 echo |
Chris@2574 | 66 echo "Diff begins:" |
Chris@2574 | 67 git diff --no-index --word-diff=color --word-diff-regex=. "$actual" "$expected" | head |
Chris@2574 | 68 echo |
Chris@2574 | 69 fi |
Chris@2574 | 70 done |