From 43e3ab019c6b6ab8e429b3dd3aa13a7b9e8316e6 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Thu, 2 Jul 2020 17:34:24 +0430 Subject: [PATCH] [tests] make tests work when ft isn't present --- test/shaping/meson.build | 8 ++++++++ test/shaping/run-tests.py | 31 ++++++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/test/shaping/meson.build b/test/shaping/meson.build index a32263116..396a0ca0e 100644 --- a/test/shaping/meson.build +++ b/test/shaping/meson.build @@ -5,6 +5,11 @@ subdir('data/text-rendering-tests') # text_rendering_tests shaping_run_tests_py = find_program('run-tests.py') +env = environment() +if conf.get('HAVE_FREETYPE', 0) == 0 + env.set('no_ft_funcs', '1') +endif + foreach file_name : in_house_tests test_name = file_name.split('.')[0].underscorify() @@ -13,6 +18,7 @@ foreach file_name : in_house_tests hb_shape, meson.current_source_dir() / 'data' / 'in-house' / 'tests' / file_name, ], + env: env, workdir: meson.current_build_dir() / '..' / '..', suite: ['shaping', 'in-house'], ) @@ -26,6 +32,7 @@ foreach file_name : aots_tests hb_shape, meson.current_source_dir() / 'data' / 'aots' / 'tests' / file_name, ], + env: env, workdir: meson.current_build_dir() / '..' / '..', suite: ['shaping', 'aots'], ) @@ -39,6 +46,7 @@ foreach file_name : text_rendering_tests hb_shape, meson.current_source_dir() / 'data' / 'text-rendering-tests' / 'tests' / file_name, ], + env: env, workdir: meson.current_build_dir() / '..' / '..', suite: ['shaping', 'text-rendering-tests'], ) diff --git a/test/shaping/run-tests.py b/test/shaping/run-tests.py index cbc61870a..28bb80935 100755 --- a/test/shaping/run-tests.py +++ b/test/shaping/run-tests.py @@ -15,6 +15,8 @@ if len (args) and args[0] == "--reference": reference = True args = args[1:] +no_ft_funcs = bool(int(os.getenv('no_ft_funcs', '0'))) + if not args or args[0].find('hb-shape') == -1 or not os.path.exists (args[0]): sys.exit ("""First argument does not seem to point to usable hb-shape.""") hb_shape, args = args[0], args[1:] @@ -59,6 +61,7 @@ for filename in args: continue fontfile, options, unicodes, glyphs_expected = line.split (":") + options = options.split () if fontfile.startswith ('/') or fontfile.startswith ('"/'): if os.name == 'nt': # Skip on Windows continue @@ -100,23 +103,25 @@ for filename in args: shutil.copyfile(fontfile, new_fontfile) fontfile = new_fontfile - glyphs1 = cmd ([hb_shape, "--font-funcs=ft", - fontfile] + extra_options + ["--unicodes", - unicodes] + (options.split (' ') if options else [])) + if "--font-funcs=ft" in options and no_ft_funcs: + skips += 1 + continue - glyphs2 = cmd ([hb_shape, "--font-funcs=ot", - fontfile] + extra_options + ["--unicodes", - unicodes] + (options.split (' ') if options else [])) - - if glyphs1 != glyphs2 and glyphs_expected != '*': - print ("FT funcs: " + glyphs1, file=sys.stderr) - print ("OT funcs: " + glyphs2, file=sys.stderr) - fails += 1 + if "--font-funcs=ot" in options or no_ft_funcs: + glyphs1 = cmd ([hb_shape, "--font-funcs=ot", fontfile] + extra_options + ["--unicodes", unicodes] + options) else: - passes += 1 + glyphs1 = cmd ([hb_shape, "--font-funcs=ft", fontfile] + extra_options + ["--unicodes", unicodes] + options) + glyphs2 = cmd ([hb_shape, "--font-funcs=ot", fontfile] + extra_options + ["--unicodes", unicodes] + options) + + if glyphs1 != glyphs2 and glyphs_expected != '*': + print ("FT funcs: " + glyphs1, file=sys.stderr) + print ("OT funcs: " + glyphs2, file=sys.stderr) + fails += 1 + else: + passes += 1 if reference: - print (":".join ([fontfile, options, unicodes, glyphs1])) + print (":".join ([fontfile, " ".join(options), unicodes, glyphs1])) continue if glyphs1.strip() != glyphs_expected and glyphs_expected != '*':