Skip to content

Commit

Permalink
add coverage test which compares current version of tat-morph to eith…
Browse files Browse the repository at this point in the history
…er HEAD (if apertium-tat was changed locally) or HEAD~1 (ifotherwise (read: on travis))
  • Loading branch information
IlnarSelimcan committed Feb 18, 2019
1 parent 604aa33 commit 6dbcb19
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,5 @@ test: all
@rm .test-ref .test-mt

check: all
cd tests/morphophonology/; python3 test.py tat
cd tests/; bash runall.bash

1 change: 1 addition & 0 deletions tests/coverage/frequency_list.url.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://www.corpus.tatar/stat/tatcorpus3.words_frequency_case-sensitive.bz2
56 changes: 56 additions & 0 deletions tests/coverage/test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

## Test current coverage of tat-morph on frequency list and compare it
## to coverage of last version of tat-morph. Return success if the
## coverage hasn't decreased, fail otherwise.
##
## By `last version' we mean:
## - HEAD if apertium-tat.git repo has local changes
## - HEAD~1 if it doesn't (when testing via `make check' is done on travis)
##
## Frequency list is a tsv file, first two fields of which are:
## - frequency
## - wordform
##
## Frequency list is not tracked in the repository. It is fetched from a URL
## given in the frequency_list.url.txt file.

if [ ! -f frequency_list.tsv ]; then
wget -i frequency_list.url.txt -O frequency_list.tsv.bz2
bzip2 -dk frequency_list.tsv.bz2
fi

FREQ_LIST=$(realpath frequency_list.tsv)

LAST=$(mktemp -d /tmp/XXXXX)

cp -r ../../ ${LAST}

pushd ${LAST}

git diff-index --quiet HEAD --
if [ $? -eq 0 ]; then
git reset --hard HEAD~1
else
git reset --hard HEAD
fi

popd

unrecognized () {
## monolingpackagedir textfile -> number
pushd $1 > /tmp/log 2>&1
./autogen.sh >> /tmp/log 2>&1
make clean >> /tmp/log 2>&1
make >> /tmp/log 2>&1
cat $2 | apertium -d . tat-morph | grep -c "*"
popd >> /tmp/log 2>&1
}

if [ $(unrecognized ../../ ${FREQ_LIST}) -le $(unrecognized ${LAST} ${FREQ_LIST}) ]; then
printf "Success!\n"
exit 0
else
printf "Fail!\n"
exit 1
fi
19 changes: 19 additions & 0 deletions tests/runall.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

alltestspass=true

cd morphophonology/; python3 test.py tat
if [ $? -ne 0 ] ; then
alltestspass=false
fi

cd ../coverage/; bash test.bash
if [ $? -ne 0 ] ; then
alltestspass=false
fi

if [ $alltestspass = "true" ] ; then
exit 0
else
exit 1
fi

0 comments on commit 6dbcb19

Please sign in to comment.