[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Mar 1 00:16:35 UTC 2018


 test/subset/run-tests.py |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

New commits:
commit b4ba71ea7ccce70e24138373774741c7f03dd24e
Author: Garret Rieger <grieger at google.com>
Date:   Wed Feb 28 15:44:00 2018 -0800

    [subset] In subset integration test pass output through ots-sanitize if present.

diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py
index f1ef4614..56cd7b4c 100755
--- a/test/subset/run-tests.py
+++ b/test/subset/run-tests.py
@@ -38,7 +38,7 @@ def fail_test(test, cli_args, message):
 	print ('  expected_file	    %s' % os.path.abspath(expected_file))
 	return 1
 
-def run_test(test):
+def run_test(test, should_check_ots):
 	out_file = os.path.join(tempfile.mkdtemp(), test.get_font_name() + '-subset.ttf')
 	cli_args = [hb_subset,
 		    "--font-file=" + test.font_path,
@@ -69,6 +69,11 @@ def run_test(test):
 		sys.stdout.flush()
 		return fail_test(test, cli_args, 'ttx for expected and actual does not match.')
 
+	if should_check_ots:
+		print ("Checking output with ots-sanitize.")
+		if not check_ots(out_file):
+			return fail_test(test, cli_args, 'ots for subsetted file fails.')
+
 	return 0
 
 def run_ttx(file):
@@ -82,6 +87,20 @@ def strip_check_sum (ttx_string):
 		       'checkSumAdjustment value="0x00000000"',
 		       ttx_string, count=1)
 
+def has_ots():
+	_, returncode = cmd(["which", "ots-sanitize"])
+	if returncode:
+		print("OTS is not present, skipping all ots checks.")
+		return False
+	return True
+
+def check_ots (path):
+	ots_report, returncode = cmd(["ots-sanitize", path])
+	if returncode:
+		print("OTS Failure: %s" % ots_report);
+		return False
+	return True
+
 args = sys.argv[1:]
 if not args or sys.argv[1].find('hb-subset') == -1 or not os.path.exists (sys.argv[1]):
 	print ("First argument does not seem to point to usable hb-subset.")
@@ -97,13 +116,15 @@ if returncode:
 	print("TTX is not present, skipping test.")
 	sys.exit (77)
 
+has_ots = has_ots()
+
 fails = 0
 for path in args:
 	with io.open(path, mode="r", encoding="utf-8") as f:
 		print ("Running tests in " + path)
 		test_suite = SubsetTestSuite(path, f.read())
 		for test in test_suite.tests():
-			fails += run_test(test)
+			fails += run_test(test, has_ots)
 
 if fails != 0:
 	print (str (fails) + " test(s) failed.")


More information about the HarfBuzz mailing list