[tests] Add --reference, for re-recording tests

This commit is contained in:
Behdad Esfahbod 2015-12-25 18:18:02 +01:00
parent fc38e6034c
commit 3fcae6d82d
1 changed files with 14 additions and 4 deletions

View File

@ -8,21 +8,31 @@ hb_shape=$top_builddir/util/hb-shape$EXEEXT
fails=0 fails=0
reference=false
if test "x$1" = x--reference; then
reference=true
shift
fi
if test $# = 0; then if test $# = 0; then
set /dev/stdin set /dev/stdin
fi fi
IFS=: IFS=:
for f in "$@"; do for f in "$@"; do
echo "Running tests in $f" $reference || echo "Running tests in $f"
while read fontfile options unicodes glyphs_expected; do while read fontfile options unicodes glyphs_expected; do
echo "Testing $fontfile:$unicodes" $reference || echo "Testing $fontfile:$unicodes"
glyphs=`$srcdir/hb-unicode-encode "$unicodes" | $hb_shape $options "$srcdir/$fontfile"` glyphs=`$srcdir/hb-unicode-encode "$unicodes" | $hb_shape $options "$srcdir/$fontfile"`
if test $? != 0; then if test $? != 0; then
echo "hb-shape failed." >&2 echo "hb-shape failed." >&2
fails=$((fails+1)) fails=$((fails+1))
continue continue
fi fi
if $reference; then
echo "$fontfile:$options:$unicodes:$glyphs"
continue
fi
if ! test "x$glyphs" = "x$glyphs_expected"; then if ! test "x$glyphs" = "x$glyphs_expected"; then
echo "Actual: $glyphs" >&2 echo "Actual: $glyphs" >&2
echo "Expected: $glyphs_expected" >&2 echo "Expected: $glyphs_expected" >&2
@ -32,8 +42,8 @@ for f in "$@"; do
done done
if test $fails != 0; then if test $fails != 0; then
echo "$fails tests failed." $reference || echo "$fails tests failed."
exit 1 exit 1
else else
echo "All tests passed." $reference || echo "All tests passed."
fi fi