Permalink
Browse files

Expand tests for coverage and CI

  • Loading branch information...
zuphilip authored and kba committed May 14, 2017
1 parent cdeb557 commit 43af19ae7fbdd27b09a208e8a65315e1c0267f28
Showing with 67 additions and 4 deletions.
  1. +2 −2 run-coverage
  2. +65 −2 run-test-ci
View
@@ -11,8 +11,8 @@ except ImportError:
exit(1)"
rm -rf .coverage*
PATH=$PWD:$PATH $COVERAGE run -p --include=$PWD/**/* ./tests/run-unit
PATH=$PWD:$PATH RUNNER="$COVERAGE run -p --include=$PWD/**/*" ./run-test-ci
PATH=$PWD:$PATH $COVERAGE run -p --include=$PWD/ocropus-*,$PWD/**/* ./tests/run-unit
PATH=$PWD:$PATH RUNNER="$COVERAGE run -p --include=$PWD/ocropus-*,$PWD/**/*" ./run-test-ci
$COVERAGE combine
rm -rf htmlcov
$COVERAGE html
View
@@ -13,36 +13,99 @@ RUNNER="${RUNNER:-python2}"
test_page() {
set -x
$RUNNER $BASE/ocropus-nlbin "$BASE/tests/testpage.png" -o temp
$RUNNER $BASE/ocropus-gpageseg 'temp/????.bin.png'
$RUNNER $BASE/ocropus-gpageseg 'temp/????.bin.png' --gray
$RUNNER $BASE/ocropus-rpred --parallel=0 --nocheck 'temp/0001/01000?.bin.png'
$RUNNER $BASE/ocropus-dewarp 'temp/0001/01001?.bin.png'
$RUNNER $BASE/ocropus-hocr 'temp/????.bin.png' -o temp.html 2>/dev/null
$RUNNER $BASE/ocropus-visualize-results temp
$RUNNER $BASE/ocropus-gtedit html temp/????/??????.bin.png -o temp-correction.html
$RUNNER $BASE/ocropus-gtedit extract temp-correction.html
set +x
}
test_conf() {
local TESTIMAGE=0079-01000d
mkdir -p temp
cp "$BASE/tests/$TESTIMAGE"* temp
set -x
$RUNNER $BASE/ocropus-rpred temp/$TESTIMAGE.png
# test different parameters of ocropus-errs
$RUNNER $BASE/ocropus-errs temp/$TESTIMAGE.gt.txt
$RUNNER $BASE/ocropus-errs temp/$TESTIMAGE.gt.txt --erroronly
# test different parameters of ocropus-econf
$RUNNER $BASE/ocropus-econf temp/$TESTIMAGE.gt.txt
$RUNNER $BASE/ocropus-econf temp/$TESTIMAGE.gt.txt --perfile temp/$TESTIMAGE.perfile.econf.txt
$RUNNER $BASE/ocropus-econf temp/$TESTIMAGE.gt.txt --allconf temp/$TESTIMAGE.allconf.econf.txt
# test with empty gt file, no txt file
echo '' > temp/econf-file.gt.txt
$RUNNER $BASE/ocropus-econf temp/econf-file.gt.txt
# test with empty gt file, existing txt file
echo '0' > temp/econf-file.txt
$RUNNER $BASE/ocropus-econf temp/econf-file.gt.txt
# test on files withouth "gt" in their file endings
$RUNNER $BASE/ocropus-errs temp/$TESTIMAGE.txt
$RUNNER $BASE/ocropus-econf temp/$TESTIMAGE.txt
# test on files where there is no corresponding txt file
cp temp/$TESTIMAGE.gt.txt temp/$TESTIMAGE.copy.gt.txt
$RUNNER $BASE/ocropus-errs temp/$TESTIMAGE.copy.gt.txt
$RUNNER $BASE/ocropus-econf temp/$TESTIMAGE.copy.gt.txt
}
test_linegen() {
$RUNNER $BASE/ocropus-linegen -m 3 -t $BASE/tests/tomsawyer.txt -f $BASE/tests/DejaVuSans.ttf
$RUNNER $BASE/ocropus-linegen -m 3 -t $BASE/tests/tomsawyer.txt -f $BASE/tests/DejaVuSans.ttf --degradations med --numdir
$RUNNER $BASE/ocropus-linegen -m 3 -t $BASE/tests/tomsawyer.txt -f $BASE/tests/DejaVuSans.ttf --degradations hi --sizes 40,50,60,70
}
test_rtrain() {
tar -zxf $BASE/tests/uw3-500.tgz
$RUNNER $BASE/ocropus-rtrain 'book/*/*.bin.png' -N 5 -o ci-test-model
}
test_nlbin() {
local TESTIMAGE=0071-010012.png
cp $BASE/tests/$TESTIMAGE temp
$RUNNER $BASE/ocropus-nlbin temp/$TESTIMAGE
$RUNNER $BASE/ocropus-nlbin temp/$TESTIMAGE -n
$RUNNER $BASE/ocropus-nlbin temp/$TESTIMAGE -n --gray
}
test_gpageseg() {
local TESTIMAGE=text-near-edge.bin.png
cp $BASE/tests/$TESTIMAGE temp
$RUNNER $BASE/ocropus-gpageseg temp/$TESTIMAGE
$RUNNER $BASE/ocropus-gpageseg temp/$TESTIMAGE -n
$RUNNER $BASE/ocropus-gpageseg temp/$TESTIMAGE -n --maxseps 3
$RUNNER $BASE/ocropus-gpageseg temp/$TESTIMAGE -n -b
$RUNNER $BASE/ocropus-gpageseg temp/$TESTIMAGE -n --usegauss
}
test_rpred() {
local TESTIMAGE=0079-01000d
cp "$BASE/tests/$TESTIMAGE"* temp
$RUNNER $BASE/ocropus-rpred temp/$TESTIMAGE.png --llocs --alocs --probabilities
$RUNNER $BASE/ocropus-rpred temp/$TESTIMAGE.png --estrate
}
test_gtedit() {
set -x
mkdir -p temp/9999
echo '0' > temp/9999/000000.gt.txt
echo 'basel' > temp/9999/000001.gt.txt
echo '2' > temp/9999/000002.gt.txt
$RUNNER $BASE/ocropus-gtedit text temp/9999/*.gt.txt -o temp/gtedit-together.gt.txt
$RUNNER $BASE/ocropus-gtedit org temp/9999/*.gt.txt -o temp/gtedit-together.org.gt.txt
mkdir -p temp/out
$RUNNER $BASE/ocropus-gtedit write temp/gtedit-together.gt.txt temp/out -x .copy.gt.txt
}
rm -rf temp
mkdir -p temp
test_page
test_conf
test_linegen
test_rtrain
test_nlbin
#this depends on #220:
#test_gpageseg
test_rpred
test_gtedit

0 comments on commit 43af19a

Please sign in to comment.