doTest.sh
865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
WORKDIR=$1
WHAT=$2
CMD=$WORKDIR/morfeusz_$WHAT
DIR=$3
echo "build test FSA for $DIR"
TMP_DICTIONARY=`mktemp -d`
DICT_NAME=test
python fsabuilder/morfeusz_builder \
--only-$WHAT \
--input-files $DIR/dictionary.tab \
--dict $DICT_NAME \
--dict-dir $TMP_DICTIONARY \
--tagset-file=$DIR/tagset.dat \
--segments-file=$DIR/segmentation.dat
echo "testing $DIR"
INPUT=$DIR/input.txt
OUTPUT=$DIR/output.txt
TMP_OUTPUT=`mktemp`
ARGS=`cat $DIR/ARGS`
$CMD --dict-dir $TMP_DICTIONARY --dict $DICT_NAME $ARGS < $INPUT > $TMP_OUTPUT
if [ $? -ne 0 ]
then
echo "command '$ARGS < $INPUT > $TMP_OUTPUT' returned non-zero exit status" >&2
exit 1
fi
diff=`diff --brief $OUTPUT $TMP_OUTPUT`
if [ "$diff" != "" ]
then
diff -u $OUTPUT $TMP_OUTPUT
echo "#### Output for '$INPUT' differs from '$OUTPUT' contents" >&2
exit 1
fi