-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·69 lines (61 loc) · 1.57 KB
/
test
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
#!/bin/bash
set -u
set -o pipefail
PATH=/tmp/texlive/bin/x86_64-linux:$PATH
travis_fold_start() {
if [ ! -z ${TRAVIS:-} ]; then
echo -e "travis_fold:start: $1\033[33;1m$2\033[0m"
else
echo -e "::group:: $1 \033[33;1m$2\033[0m"
fi
}
travis_fold_end() {
if [ ! -z ${TRAVIS:-} ]; then
echo -e "\ntravis_fold:end: $1\r"
else
echo -e "\n::endgroup::\n"
fi
}
latexclean() {
rm -f *.bbl *.aux *.log *.out *.bcf *.blg *.fls *.hd *.fdb_latexmk *.run.xml *.syctex.gz
}
latexmake() {
TEXMAIN=$1
travis_fold_start latexmk.1 "latexmk $TEXMAIN"
latexclean
latexmk -silent -halt-on-error -interaction=nonstopmode -gg --pdf $TEXMAIN
if [ $? -ne 0 ]; then
travis_fold_end latexmk.1
echo "Error: latexmk failed"
LOGFILE=${TEXMAIN%.*}.log
cat "$LOGFILE"
exit 1
fi
travis_fold_end latexmk.1
}
check_snapshot() {
name=$1
pdftoppm -scale-to 800 -png ${name}.pdf ${name}-new
for new in ${name}-new-*.png; do
old=${new//"-new"}
if [ ! -e $old ]; then
echo "Warning: $old does not exist, creating it now"
mv $new $old
continue
fi
diff -q ${old} ${new} > /dev/null
if [ $? -ne 0 ]; then
echo "Error: ${old} and ${new} are different (use diffimg to visualize the differences)"
ERROR=1
else
rm -f ${new}
fi
done
}
ERROR=0
for tex in test-*.tex; do
latexmake "$tex"
testname=$(basename $tex .tex)
check_snapshot $testname
done
exit $ERROR