From b4ba71ea7ccce70e24138373774741c7f03dd24e Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 28 Feb 2018 15:44:00 -0800 Subject: [PATCH] [subset] In subset integration test pass output through ots-sanitize if present. --- test/subset/run-tests.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py index f1ef4614a..56cd7b4c3 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.")