|
| 1 | +#!/bin/bash |
| 2 | +# @configure_input@ |
| 3 | + |
| 4 | +# Test that running pipeline from bundle has same results as gold standard |
| 5 | +# (from previous runs) |
| 6 | + |
| 7 | +if ! test $# -ge 4 ; then |
| 8 | + echo |
| 9 | + echo "Usage: $0 ARCHIVE TESTFILE GOLD VARIANT [LEVEL [THRESHOLD]]" |
| 10 | + echo |
| 11 | + echo "were:" |
| 12 | + echo " ARCHIVE is the .drb/.ts file" |
| 13 | + echo " TESTFILE is input text" |
| 14 | + echo " GOLD is expected output" |
| 15 | + echo " VARIANT is the variant in the pipeline" |
| 16 | + echo " LEVEL is the things to match: tags, lemmas, suffixed, all" |
| 17 | + echo " THRESHOLD is needed recall %" |
| 18 | + echo |
| 19 | + echo "LEVEL defaults to maintags if not given" |
| 20 | + echo "THRESHOLD defaults to 99 % if not given" |
| 21 | + exit 77 |
| 22 | +fi |
| 23 | + |
| 24 | +ANSIFILTER="@ANSIFILTER@" |
| 25 | +runner="@DIVVUN_RUNTIME@" |
| 26 | +python="@PYTHON@" |
| 27 | +comparator="@GIELLA_CORE@/scripts/vislcg-compare.py" |
| 28 | +archive=$1 |
| 29 | +testfile=$2 |
| 30 | +goldfile=$3 |
| 31 | +variant=$4 |
| 32 | +level=tags |
| 33 | +threshold=99 |
| 34 | +if test $# -ge 5 ; then |
| 35 | + level=$5 |
| 36 | +fi |
| 37 | +if test $# -ge 6 ; then |
| 38 | + threshold=$6 |
| 39 | +fi |
| 40 | + |
| 41 | + |
| 42 | +. "@GIELLA_CORE@/scripts/termcolors.bash" |
| 43 | + |
| 44 | +if ! test -f $comparator ; then |
| 45 | + printf "%sskip%s missing comparation script %s" "$light_blue" "$reset" \ |
| 46 | + "$comparator" |
| 47 | +fi |
| 48 | +if ! test -f $runner ; then |
| 49 | + printf "%sskip%s missing pipespec runner from libdivvun" \ |
| 50 | + "$light_blue" "$reset" |
| 51 | + exit 77 |
| 52 | +fi |
| 53 | +if ! test -f $archive ; then |
| 54 | + printf "%sskip%s missing pipespec archive %s\n" "$light_blue" "$reset" \ |
| 55 | + "$archive" |
| 56 | + exit 77 |
| 57 | +fi |
| 58 | +if ! test -f $testfile ; then |
| 59 | + printf "%sskip%s missing test data %s\n" "$light_blue" "$reset" \ |
| 60 | + "$testfile" |
| 61 | + exit 77 |
| 62 | +fi |
| 63 | +if ! test -f $goldfile ; then |
| 64 | + printf "%sskip%s missing gold data %s\n" "$light_blue" "$reset" \ |
| 65 | + "$goldfile" |
| 66 | + echo "hint: $runner -a $archive -n $variant < $testfile > $goldfile" |
| 67 | + exit 77 |
| 68 | +fi |
| 69 | + |
| 70 | +outfile=$(mktemp -t giella-pipe-test.XXXXXXXXXXX) |
| 71 | + |
| 72 | +$runner run -p "$archive" -P "$variant" < "$testfile" | $ANSIFILTER > "$outfile" |
| 73 | +rv=$? |
| 74 | +if test $rv -gt 0 ; then |
| 75 | + printf "%sfail%s running $runner failed (see above?)\n" "$red" "$reset" |
| 76 | + exit $rv |
| 77 | +fi |
| 78 | +if cmp "$goldfile" "$outfile" > /dev/null ; then |
| 79 | + printf "%spass%s - exact match\n" "$green" "$reset" |
| 80 | +elif ! $python $comparator -r "$goldfile" -H "$outfile" \ |
| 81 | + -t "$threshold" -L "$level" ; then |
| 82 | + printf "%sfail%s - outputs differ too muchly:\n" "$red" "$reset" |
| 83 | + diff -u "$goldfile" "$outfile" |
| 84 | + exit 1 |
| 85 | +else |
| 86 | + printf "%spass%s - small regressions:\n" "$green" "$reset" |
| 87 | + diff -u "$goldfile" "$outfile" |
| 88 | + exit 0 |
| 89 | +fi |
0 commit comments