-
Notifications
You must be signed in to change notification settings - Fork 592
/
run-test-ci
executable file
·133 lines (121 loc) · 4.78 KB
/
run-test-ci
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash -e
# Usage: ./run-test-ci [tests...]
#
# Examples:
#
# ./run-test-ci # Run all tests
# ./run-test-ci page conf # Run only 'test_page' and 'test_conf'
#
BASE=$(dirname $0)
# 'RUNNER' is the binary that the scripts are executed by. It defaults to
# 'python2' if not set in the environment.
# Other examples:
# PATH=$PWD:$PATH RUNNER='python2 -m coverage run --include=$PWD/**/*' ./run-test
# PATH=$PWD:$PATH RUNNER='python3' ./run-test
# See ./run-coverage for a real example.
RUNNER="${RUNNER:-python2}"
test_page() {
set -x
$RUNNER $BASE/ocropus-nlbin "$BASE/tests/testpage.png" -o temp
$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
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_rtrain_files() {
tar -zxf $BASE/tests/uw3-500.tgz
find 'book' -name '*.bin.png' > INPUT_FILES
$RUNNER $BASE/ocropus-rtrain -f INPUT_FILES -N 5 -o ci-test-model
rm INPUT_FILES
}
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
cp $BASE/tests/table.bin.png $BASE/tests/table.mask.png temp
$RUNNER $BASE/ocropus-gpageseg temp/table.bin.png --debug -n --minscale 7 --maxcolseps 0
}
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
if (( $# > 0 ));then
for test in "$@";do
test_$test
done
else
test_page
test_conf
test_linegen
test_rtrain
test_rtrain_files
test_nlbin
test_gpageseg
test_rpred
test_gtedit
fi