[Piglit] [PATCH 16/35] framework/test: use relative paths for GLSLParser tests

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


---
 framework/test/glsl_parser_test.py | 13 ++++++++++---
 tests/all.py                       |  4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index 46344a8..35eadfe 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -33,7 +33,7 @@ import six
 from framework import exceptions
 from .base import TestIsSkip
 from .opengl import FastSkipMixin
-from .piglit_test import PiglitBaseTest, TEST_BIN_DIR
+from .piglit_test import PiglitBaseTest, TEST_BIN_DIR, ROOT_DIR
 
 __all__ = [
     'GLSLParserTest',
@@ -95,11 +95,12 @@ class Parser(object):
         self.gl_required = set()
         self.glsl_es_version = None
         self.glsl_version = None
+        abs_filepath = os.path.join(ROOT_DIR, filepath)
 
         try:
-            with io.open(filepath, mode='r', encoding='utf-8') as testfile:
+            with io.open(abs_filepath, mode='r', encoding='utf-8') as testfile:
                 testfile = testfile.read()
-                self.config = self.parse(testfile, filepath)
+                self.config = self.parse(testfile, abs_filepath)
             self.command = self.get_command(filepath)
         except GLSLParserInternalError as e:
             raise exceptions.PiglitFatalError(
@@ -278,6 +279,12 @@ class GLSLParserTest(FastSkipMixin, PiglitBaseTest):
             command, run_concurrent=True, gl_required=gl_required,
             glsl_version=glsl_version, glsl_es_version=glsl_es_version)
 
+    @PiglitBaseTest.command.getter
+    def command(self):
+        command = super(GLSLParserTest, self).command
+        glslfile = os.path.join(ROOT_DIR, command[1])
+        return [command[0], glslfile] + command[2:]
+
     @classmethod
     def new(cls, filepath):
         parsed = Parser(filepath)
diff --git a/tests/all.py b/tests/all.py
index cf6ee5a..e0c7311 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -305,8 +305,8 @@ for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
         groupname = grouptools.from_path(os.path.relpath(dirpath, basedir))
         for filename in filenames:
             testname, ext = os.path.splitext(filename)
+            dirname = os.path.relpath(dirpath, ROOT_DIR)
             if ext == '.shader_test':
-                dirname = os.path.relpath(dirpath, ROOT_DIR)
                 if PROCESS_ISOLATION:
                     test = ShaderTest.new(os.path.join(dirname, filename))
                 else:
@@ -314,7 +314,7 @@ for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
                     continue
             elif ext in ['.vert', '.tesc', '.tese', '.geom', '.frag', '.comp']:
                 try:
-                    test = GLSLParserTest.new(os.path.join(dirpath, filename))
+                    test = GLSLParserTest.new(os.path.join(dirname, filename))
                 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