# 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
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:
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)
return 0
def run_ttx(file):
+ print ("ttx %s" % file)
cli_args = ["ttx",
+ "-q",
"-o-",
file]
return cmd(cli_args)
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.")