comparison tests/test-summaries.sh @ 28:102bb1729184 sonic-annotator-0.4

* Test fixes for cases where the behaviour has actually been fixed for 0.4 * Emphasise this change in CHANGELOG
author Chris Cannam
date Fri, 25 Sep 2009 12:00:58 +0000
parents 0f7c8b9410ef
children 94d988cef54e
comparison
equal deleted inserted replaced
27:9fef62a3696d 28:102bb1729184
9 tmpcmp1=$mypath/tmp_3_$$ 9 tmpcmp1=$mypath/tmp_3_$$
10 tmpcmp2=$mypath/tmp_4_$$ 10 tmpcmp2=$mypath/tmp_4_$$
11 11
12 trap "rm -f $tmpfile $tmpcanonical $tmpcmp1 $tmpcmp2" 0 12 trap "rm -f $tmpfile $tmpcanonical $tmpcmp1 $tmpcmp2" 0
13 13
14 fail() { 14 . test-include.sh
15
16 faildiff() {
15 echo "Test failed: $1" 17 echo "Test failed: $1"
16 if [ -n "$2" -a -n "$3" ]; then 18 if [ -n "$2" -a -n "$3" ]; then
17 echo "Output follows:" 19 echo "Output follows:"
18 echo "--" 20 echo "--"
19 cat $2 21 cat $2
22 echo "--" 24 echo "--"
23 cat $3 25 cat $3
24 echo "--" 26 echo "--"
25 echo "Diff:" 27 echo "Diff:"
26 echo "--" 28 echo "--"
27 diff -u $2 $3 29 sdiff -w78 $2 $3
28 echo "--" 30 echo "--"
29 fi 31 fi
30 exit 1 32 exit 1
31 } 33 }
32 34
33 compare() { 35 compare() {
34 a=$1 36 a=$1
35 b=$2 37 b=$2
36 sort $a > $tmpcmp1 38 sort $a > $tmpcmp1
37 sort $b > $tmpcmp2 39 sort $b > $tmpcmp2
38 cmp -s $tmpcmp1 $tmpcmp2 40 csvcompare $tmpcmp1 $tmpcmp2
39 } 41 }
40 42
41 # transform to which we have to add summarisation on command line 43 # transform to which we have to add summarisation on command line
42 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3 44 transform=$mypath/transforms/transforms-nosummaries-percussiononsets-detectionfunction.n3
43 expected=$mypath/expected/transforms-summaries-percussiononsets 45 expected=$mypath/expected/transforms-summaries-percussiononsets
47 49
48 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ 50 $r -t $transform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
49 fail "Fails to run transform $transform" 51 fail "Fails to run transform $transform"
50 52
51 compare $tmpfile ${expected}.csv || \ 53 compare $tmpfile ${expected}.csv || \
52 fail "Output mismatch for transform $transform" $tmpfile ${expected}.csv 54 faildiff "Output mismatch for transform $transform" $tmpfile ${expected}.csv
53 55
54 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \ 56 $r -t $transform -w csv --csv-stdout -S mean $infile > $tmpfile 2>/dev/null || \
55 fail "Fails to run transform $transform with summary type mean" 57 fail "Fails to run transform $transform with summary type mean"
56 58
57 compare $tmpfile ${expected}-with-mean.csv || \ 59 compare $tmpfile ${expected}-with-mean.csv || \
58 fail "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv 60 faildiff "Output mismatch for transform $transform with summary type mean" $tmpfile ${expected}-with-mean.csv
59 61
60 $r -t $transform -w csv --csv-stdout -S min -S max -S mean -S median -S mode -S sum -S variance -S sd -S count --summary-only $infile > $tmpfile 2>/dev/null || \ 62 $r -t $transform -w csv --csv-stdout -S min -S max -S mean -S median -S mode -S sum -S variance -S sd -S count --summary-only $infile > $tmpfile 2>/dev/null || \
61 fail "Fails to run transform $transform with all summary types and summary-only" 63 fail "Fails to run transform $transform with all summary types and summary-only"
62 64
63 compare $tmpfile ${expected}-all-summaries-only.csv || \ 65 compare $tmpfile ${expected}-all-summaries-only.csv || \
64 fail "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv 66 faildiff "Output mismatch for transform $transform with all summary types and summary-only" $tmpfile ${expected}-all-summaries-only.csv
65 67
66 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \ 68 $r -t $stransform -w csv --csv-stdout $infile > $tmpfile 2>/dev/null || \
67 fail "Fails to run transform $stransform with CSV output" 69 fail "Fails to run transform $stransform with CSV output"
68 70
69 compare $tmpfile ${sexpected}.csv || \ 71 compare $tmpfile ${sexpected}.csv || \
70 fail "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv 72 faildiff "Output mismatch for transform $stransform" $tmpfile ${sexpected}.csv
71 73
72 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \ 74 $r -t $stransform -w rdf --rdf-stdout $infile > $tmpfile 2>/dev/null || \
73 fail "Fails to run transform $stransform with RDF output" 75 fail "Fails to run transform $stransform with RDF output"
74 76
75 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical || 77 rapper -i turtle $tmpfile -o turtle 2>/dev/null | grep -v '^@prefix :' | grep -v 'file:/' > $tmpcanonical ||
76 fail "Fails to produce parseable RDF/TTL for transform $stransform" 78 fail "Fails to produce parseable RDF/TTL for transform $stransform"
77 79
78 compare $tmpcanonical ${sexpected}.n3 || \ 80 compare $tmpcanonical ${sexpected}.n3 || \
79 fail "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3 81 faildiff "Output mismatch for canonicalised version of transform $stransform" $tmpcanonical ${sexpected}.n3
80 82
81 exit 0 83 exit 0
82 84