Imported Upstream version 1.8.1
[platform/upstream/harfbuzz.git] / test / subset / run-tests.py
index 56cd7b4..1cd1a19 100755 (executable)
@@ -3,7 +3,7 @@
 # Runs a subsetting test suite. Compares the results of subsetting via harfbuz
 # to subsetting via fonttools.
 
-from __future__ import print_function
+from __future__ import print_function, division, absolute_import
 
 import io
 from difflib import unified_diff
@@ -19,9 +19,9 @@ from subset_test_suite import SubsetTestSuite
 def cmd(command):
        p = subprocess.Popen (
                command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-       p.wait ()
-       print (p.stderr.read (), end="") # file=sys.stderr
-       return p.stdout.read (), p.returncode
+       (stdoutdata, stderrdata) = p.communicate()
+       print (stderrdata, end="") # file=sys.stderr
+       return stdoutdata, p.returncode
 
 def read_binary(file_path):
        with open(file_path, 'rb') as f:
@@ -60,6 +60,7 @@ def run_test(test, should_check_ots):
        if return_code:
                return fail_test(test, cli_args, "ttx (actual) returned %d" % (return_code))
 
+       print ("stripping checksums.")
        expected_ttx = strip_check_sum (expected_ttx)
        actual_ttx = strip_check_sum (actual_ttx)
 
@@ -77,7 +78,9 @@ def run_test(test, should_check_ots):
        return 0
 
 def run_ttx(file):
+       print ("ttx %s" % file)
        cli_args = ["ttx",
+                   "-q",
                    "-o-",
                    file]
        return cmd(cli_args)
@@ -85,9 +88,9 @@ def run_ttx(file):
 def strip_check_sum (ttx_string):
        return re.sub ('checkSumAdjustment value=["]0x([0-9a-fA-F])+["]',
                       'checkSumAdjustment value="0x00000000"',
-                      ttx_string, count=1)
+                      ttx_string.decode (), count=1)
 
-def has_ots():
+def has_ots ():
        _, returncode = cmd(["which", "ots-sanitize"])
        if returncode:
                print("OTS is not present, skipping all ots checks.")