Imported Upstream version 2.3.1
[platform/upstream/harfbuzz.git] / test / subset / subset_test_suite.py
index 3538650..5e3368e 100644 (file)
@@ -28,6 +28,14 @@ class Test:
                                       self.unicodes(),
                                       font_base_name_parts[1])
 
+       def get_font_extension(self):
+               font_base_name = os.path.basename(self.font_path)
+               font_base_name_parts = os.path.splitext(font_base_name)
+               return font_base_name_parts[1]
+
+       def applicable(self):
+               return self.profile_path.find("desubroutinize") < 0 or self.get_font_extension() == "otf"
+
 # A group of tests to perform on the subsetter. Each test
 # Identifies a font a subsetting profile, and a subset to be cut.
 class SubsetTestSuite:
@@ -47,7 +55,7 @@ class SubsetTestSuite:
                if not os.path.exists(output_dir):
                        os.mkdir(output_dir)
                if not os.path.isdir(output_dir):
-                       raise Error("%s is not a directory." % output_dir)
+                       raise Exception("%s is not a directory." % output_dir)
 
                return output_dir
 
@@ -57,7 +65,9 @@ class SubsetTestSuite:
                        for profile in self.profiles:
                                profile = os.path.join(self._base_path(), "profiles", profile)
                                for subset in self.subsets:
-                                       yield Test(font, profile, subset)
+                                       test = Test(font, profile, subset)
+                                       if test.applicable():
+                                               yield test
 
        def _base_path(self):
                return os.path.dirname(os.path.dirname(self.test_path))