[Piglit] [PATCH 28/35] fix glslparser test for out of tree builds

Dylan Baker dylan at pnwbakers.com
Wed Apr 4 22:27:16 UTC 2018


---
 framework/test/glsl_parser_test.py | 19 +++++++++++++------
 tests/glslparser.py                | 13 +++++++++++--
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index 88646c9..8840c2d 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -89,7 +89,7 @@ class Parser(object):
     _CONFIG_KEYS = frozenset(['expect_result', 'glsl_version',
                               'require_extensions', 'check_link'])
 
-    def __init__(self, filepath):
+    def __init__(self, filepath, installpath=None):
         # a set that stores a list of keys that have been found already
         self.__found_keys = set()
         self.gl_required = set()
@@ -101,7 +101,7 @@ class Parser(object):
             with io.open(abs_filepath, mode='r', encoding='utf-8') as testfile:
                 testfile = testfile.read()
                 self.config = self.parse(testfile, abs_filepath)
-            self.command = self.get_command(filepath)
+            self.command = self.get_command(filepath, installpath)
         except GLSLParserInternalError as e:
             raise exceptions.PiglitFatalError(
                 'In file "{}":\n{}'.format(filepath, six.text_type(e)))
@@ -153,7 +153,7 @@ class Parser(object):
         else:
             return 'glslparsertest'
 
-    def get_command(self, filepath):
+    def get_command(self, filepath, installpath):
         """ Create the command argument to pass to super()
 
         This private helper creates a configparser object, then reads in the
@@ -172,7 +172,7 @@ class Parser(object):
         glsl = self.config['glsl_version']
         command = [
             self.pick_binary(glsl),
-            filepath,
+            installpath or filepath,
             self.config['expect_result'],
             self.config['glsl_version']
         ]
@@ -282,8 +282,15 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest):
         return [command[0], glslfile] + command[2:]
 
     @classmethod
-    def new(cls, filepath):
-        parsed = Parser(filepath)
+    def new(cls, filepath, installpath=None):
+        """Parse a file and create an instance.
+
+        :param str filepath: the file to parse
+        :param Optional[str] installpath:
+            The relative path the file will be isntalled to if different than
+            filepath
+        """
+        parsed = Parser(filepath, installpath)
         return cls(
             parsed.command,
             gl_required=parsed.gl_required,
diff --git a/tests/glslparser.py b/tests/glslparser.py
index 9d50dab..b7de9f6 100644
--- a/tests/glslparser.py
+++ b/tests/glslparser.py
@@ -17,15 +17,24 @@ profile = TestProfile()
 
 # Find and add all shader tests.
 basepath = os.path.normpath(os.path.join(TESTS_DIR, '..'))
+gen_basepath = os.path.relpath(os.path.join(GENERATED_TESTS_DIR, '..'), basepath)
+
 for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
+    isgenerated = basedir == GENERATED_TESTS_DIR
     for dirpath, _, filenames in os.walk(basedir):
         groupname = grouptools.from_path(os.path.relpath(dirpath, basedir))
         for filename in filenames:
             testname, ext = os.path.splitext(filename)
             if ext in ['.vert', '.tesc', '.tese', '.geom', '.frag', '.comp']:
+                dirname = os.path.relpath(dirpath, basepath)
+                filepath = os.path.join(dirname, filename)
+                if isgenerated:
+                    installpath = os.path.relpath(filepath, gen_basepath)
+                else:
+                    installpath = None
+
                 try:
-                    test = GLSLParserTest.new(
-                        os.path.join(os.path.relpath(dirpath, basepath), filename))
+                    test = GLSLParserTest.new(filepath, installpath)
                 except GLSLParserNoConfigError:
                     # In the event that there is no config assume that it is a
                     # legacy test, and continue
-- 
git-series 0.9.1


More information about the Piglit mailing list