added memory consumption and improved error handling for testing
parent
ee00fd7173
commit
ddb997de1d
128
test/testing.sh
128
test/testing.sh
|
@ -8,7 +8,7 @@ set -e
|
||||||
|
|
||||||
## -- pass getopts
|
## -- pass getopts
|
||||||
|
|
||||||
usage() { echo "Usage: dev-install.sh [-q]"; }
|
usage() { echo "Usage: testing.sh [-q]"; }
|
||||||
|
|
||||||
verbose=1
|
verbose=1
|
||||||
|
|
||||||
|
@ -23,7 +23,15 @@ while getopts ":q" opt; do
|
||||||
done
|
done
|
||||||
|
|
||||||
## -- variables
|
## -- variables
|
||||||
|
# colors
|
||||||
|
Red="\033[0;31m"
|
||||||
|
Green="\033[0;32m"
|
||||||
|
Reset="\033[0;m"
|
||||||
|
# directory
|
||||||
TESTDIR="../test"
|
TESTDIR="../test"
|
||||||
|
if [ -d ../tikz-trackschematic ]; then
|
||||||
|
cd test/
|
||||||
|
fi
|
||||||
|
|
||||||
## -- commands
|
## -- commands
|
||||||
|
|
||||||
|
@ -83,6 +91,10 @@ check_imagemagick() {
|
||||||
check_tex_distro
|
check_tex_distro
|
||||||
check_trackschematic
|
check_trackschematic
|
||||||
check_imagemagick
|
check_imagemagick
|
||||||
|
if [ ! -d $TESTDIR ]; then
|
||||||
|
echo "${Red}Do not find test directory!${Reset}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "`echo -n`" = "-n" ]; then
|
if [ "`echo -n`" = "-n" ]; then
|
||||||
n=""
|
n=""
|
||||||
|
@ -92,24 +104,12 @@ else
|
||||||
c=""
|
c=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## -- doing the tests
|
## -- Testing
|
||||||
#
|
|
||||||
# compare metrics
|
|
||||||
#
|
|
||||||
# AE: absolute error count, number of different pixels (-fuzz affected)
|
|
||||||
# DSSIM: structural dissimilarity index
|
|
||||||
# FUZZ: mean color distance
|
|
||||||
# MAE: mean absolute error (normalized), average channel error distance
|
|
||||||
# MEPP: mean error per pixel (normalized mean error, normalized peak error)
|
|
||||||
# MSE: mean error squared, average of the channel error squared
|
|
||||||
# NCC: normalized cross correlation
|
|
||||||
# PAE: peak absolute (normalized peak absolute)
|
|
||||||
# PHASH: perceptual hash for the sRGB and HCLp colorspaces.
|
|
||||||
# PSNR: peak signal to noise ratio
|
|
||||||
# RMSE: root mean squared (normalized root mean squared)
|
|
||||||
# SSIM: structural similarity index
|
|
||||||
|
|
||||||
mkdir -p .testing
|
mkdir -p .tex
|
||||||
|
test_status=0
|
||||||
|
# Start with an empty List:
|
||||||
|
FAILED=""
|
||||||
|
|
||||||
if [ $verbose = 1 ]; then
|
if [ $verbose = 1 ]; then
|
||||||
echo "==========="
|
echo "==========="
|
||||||
|
@ -118,22 +118,100 @@ if [ $verbose = 1 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for TEST in `ls $TESTDIR/*.tex`; do
|
for TEST in `ls $TESTDIR/*.tex`; do
|
||||||
|
# setup
|
||||||
FILE=$(basename "$TEST") # remove path
|
FILE=$(basename "$TEST") # remove path
|
||||||
NAME=${FILE%.*} # remove extension
|
NAME=${FILE%.*} # remove extension
|
||||||
|
add_to_list=0
|
||||||
|
#
|
||||||
if [ $verbose = 1 ]; then
|
if [ $verbose = 1 ]; then
|
||||||
echo $n " - '$NAME' test: $c"
|
echo "$NAME test:"
|
||||||
fi
|
fi
|
||||||
pdflatex -output-directory=.testing -interaction=batchmode -halt-on-error $FILE 2>&1 > /dev/null
|
#
|
||||||
|
#
|
||||||
|
## TeX build
|
||||||
|
#
|
||||||
|
exit_code_pdflatex=0
|
||||||
|
pdflatex -output-directory=.tex -interaction=batchmode -halt-on-error ${NAME}.tex >> /dev/null 2>&1 || exit_code_pdflatex=1
|
||||||
|
# understanding TeX statistics:
|
||||||
|
# -> https://tex.stackexchange.com/questions/26208/components-of-latexs-memory-usage
|
||||||
|
# TOP=$(grep -n "Here is how much of TeX's memory you used:" .tex/${NAME}.log | cut -d: -f1)
|
||||||
|
# BOTTOM=$(($(grep -n "stack positions out of" .tex/${NAME}.log | cut -d: -f1) + 1))
|
||||||
|
# awk "NR>$TOP&&NR<$BOTTOM" .tex/${NAME}.log > .tex/${NAME}.statistics.log
|
||||||
|
memory_usage=$(grep "words of memory out of" .tex/${NAME}.log | cut -d " " -f2)
|
||||||
|
memory_usage=$(($memory_usage/1000))
|
||||||
|
if [ $exit_code_pdflatex = 0 ]; then
|
||||||
if [ $verbose = 1 ]; then
|
if [ $verbose = 1 ]; then
|
||||||
echo $n "build complete, $c" # it is actually not in percent! But it helps them humans...
|
echo $n " - ${Green}build succesful${Reset}: $c"
|
||||||
|
echo "${memory_usage}k of memory used."
|
||||||
|
# cat .tex/${NAME}.statistics.log
|
||||||
fi
|
fi
|
||||||
compare -metric RMSE -colorspace RGB .testing/${NAME}.pdf ${NAME}_expected.pdf NULL:
|
else
|
||||||
|
test_status=1
|
||||||
|
add_to_list=1
|
||||||
if [ $verbose = 1 ]; then
|
if [ $verbose = 1 ]; then
|
||||||
echo "% difference." # it is actually not in percent! But it helps them humans...
|
echo " - ${Red}build failed${Reset}."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
#
|
||||||
|
## compare images
|
||||||
|
#
|
||||||
|
# compare metrics
|
||||||
|
# AE: absolute error count, number of different pixels (-fuzz affected)
|
||||||
|
# DSSIM: structural dissimilarity index
|
||||||
|
# FUZZ: mean color distance
|
||||||
|
# MAE: mean absolute error (normalized), average channel error distance
|
||||||
|
# MEPP: mean error per pixel (normalized mean error, normalized peak error)
|
||||||
|
# MSE: mean error squared, average of the channel error squared
|
||||||
|
# NCC: normalized cross correlation
|
||||||
|
# PAE: peak absolute (normalized peak absolute)
|
||||||
|
# PHASH: perceptual hash for the sRGB and HCLp colorspaces.
|
||||||
|
# PSNR: peak signal to noise ratio
|
||||||
|
# RMSE: root mean squared (normalized root mean squared)
|
||||||
|
# SSIM: structural similarity index
|
||||||
|
#
|
||||||
|
exit_code_compare=0
|
||||||
|
compare -metric RMSE -colorspace RGB .tex/${NAME}.pdf ${NAME}_expected.pdf NULL: >> /dev/null 2>&1 || exit_code_compare=1
|
||||||
|
if [ $exit_code_compare = 0 ]; then
|
||||||
|
if [ $verbose = 1 ]; then
|
||||||
|
echo " - ${Green}comparison succesful${Reset}."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
test_status=1
|
||||||
|
add_to_list=1
|
||||||
|
if [ $verbose = 1 ]; then
|
||||||
|
echo " - ${Red}comparison failed${Reset}."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
#
|
||||||
|
## if a test failed add to list
|
||||||
|
if [ $add_to_list = 1 ]; then
|
||||||
|
if [ -z $FAILED ]; then
|
||||||
|
# first item
|
||||||
|
FAILED="$NAME"
|
||||||
|
else
|
||||||
|
FAILED="$FAILED, $NAME"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $verbose = 1 ]; then
|
## -- finishing
|
||||||
|
|
||||||
|
if [ $test_status = 0 ]; then
|
||||||
|
if [ $verbose = 1 ]; then
|
||||||
echo "-----------"
|
echo "-----------"
|
||||||
echo "tests passed!"
|
echo "${Green}All tests passed!${Reset}"
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ $verbose = 1 ]; then
|
||||||
|
echo "-----------"
|
||||||
|
echo "${Red}The following tests failed: ${FAILED}!${Reset}"
|
||||||
|
else
|
||||||
|
echo "${Red}Some or all tests failed!${Reset}"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
EOF
|
Loading…
Reference in New Issue