[tests] make tests work when ft isn't present
diff --git a/test/shaping/meson.build b/test/shaping/meson.build
index a322631..396a0ca 100644
--- a/test/shaping/meson.build
+++ b/test/shaping/meson.build
@@ -5,6 +5,11 @@
 
 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 @@
       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 @@
       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 @@
       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 cbc6187..28bb809 100755
--- a/test/shaping/run-tests.py
+++ b/test/shaping/run-tests.py
@@ -15,6 +15,8 @@
 	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 @@
 			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 @@
 			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 != '*':