Imported Upstream version 1.2.7
[platform/upstream/harfbuzz.git] / test / shaping / run-tests.sh
index a2cdf32..021c6f8 100755 (executable)
@@ -8,16 +8,34 @@ hb_shape=$top_builddir/util/hb-shape$EXEEXT
 
 fails=0
 
+reference=false
+if test "x$1" = x--reference; then
+       reference=true
+       shift
+fi
+
 if test $# = 0; then
        set /dev/stdin
 fi
 
-IFS=:
 for f in "$@"; do
-       echo "Running tests in $f"
-       while read fontfile unicodes glyphs_expected; do
-               echo "Testing $fontfile:$unicodes"
-               glyphs=`$srcdir/hb-unicode-encode "$unicodes" | $hb_shape "$srcdir/$fontfile"`
+       $reference || echo "Running tests in $f"
+       while IFS=: read fontfile options unicodes glyphs_expected; do
+               if echo "$fontfile" | grep -q '^#'; then
+                       $reference || echo "Skipping $fontfile:$unicodes"
+                       continue
+               fi
+               $reference || echo "Testing $fontfile:$unicodes"
+               glyphs=`$srcdir/hb-unicode-encode "$unicodes" | $hb_shape $options "$srcdir/$fontfile"`
+               if test $? != 0; then
+                       echo "hb-shape failed." >&2
+                       fails=$((fails+1))
+                       continue
+               fi
+               if $reference; then
+                       echo "$fontfile:$options:$unicodes:$glyphs"
+                       continue
+               fi
                if ! test "x$glyphs" = "x$glyphs_expected"; then
                        echo "Actual:   $glyphs" >&2
                        echo "Expected: $glyphs_expected" >&2
@@ -27,8 +45,8 @@ for f in "$@"; do
 done
 
 if test $fails != 0; then
-       echo "$fails tests failed."
+       $reference || echo "$fails tests failed."
        exit 1
 else
-       echo "All tests passed."
+       $reference || echo "All tests passed."
 fi