Commit 2f2c0cbd authored by Dylan Baker's avatar Dylan Baker

fix glslparser test for out of tree builds

Tested-by: Rafael Antognolli's avatarRafael Antognolli <rafael.antognolli@intel.com>
parent 8786e154
......@@ -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,
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment