Commit 1be0b641 authored by Dylan Baker's avatar Dylan Baker

shader_tests: correctly generate xml during out of tree builds

Tested-by: Rafael Antognolli's avatarRafael Antognolli <rafael.antognolli@intel.com>
parent 400dcd5c
......@@ -167,12 +167,18 @@ class ShaderTest(FastSkipMixin, PiglitBaseTest):
glsl_es_version=glsl_es_version)
@classmethod
def new(cls, filename):
def new(cls, filename, installed_name=None):
"""Parse an XML file and create a new instance.
:param str filename: The name of the file to parse
:param str installed_name: The relative path to the file when installed
if not the same as the parsed name
"""
parser = Parser(filename)
parser.parse()
return cls(
[parser.prog, parser.filename],
[parser.prog, installed_name or filename],
run_concurrent=True,
gl_required=parser.gl_required,
gl_version=parser.gl_version,
......@@ -215,7 +221,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
self.skips = [FastSkip(**s) for s in skips]
@classmethod
def new(cls, filenames):
def new(cls, filenames, installednames=None):
# TODO
assert filenames
prog = None
......@@ -257,7 +263,7 @@ class MultiShaderTest(ReducedProcessMixin, PiglitBaseTest):
'glsl_es_version': parser.glsl_es_version,
})
return cls(prog, filenames, subtests, skips)
return cls(prog, installednames or filenames, subtests, skips)
def _process_skips(self):
r_files = []
......
......@@ -6,6 +6,7 @@ from __future__ import (
import collections
import os
from six.moves import zip
import six
from framework.options import OPTIONS
......@@ -22,17 +23,26 @@ shader_tests = collections.defaultdict(list)
# 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 == '.shader_test':
dirname = os.path.relpath(dirpath, basepath)
filepath = os.path.join(dirname, filename)
if isgenerated:
installpath = os.path.relpath(filepath, gen_basepath)
else:
installpath = None
if OPTIONS.process_isolation:
test = ShaderTest.new(os.path.join(dirname, filename))
test = ShaderTest.new(filepath, installpath)
else:
shader_tests[groupname].append(os.path.join(dirname, filename))
shader_tests[groupname].append((filepath, installpath))
continue
else:
continue
......@@ -46,11 +56,24 @@ for basedir in [TESTS_DIR, GENERATED_TESTS_DIR]:
# this dictionary is constructed, then added to the actual test dictionary.
for group, files in six.iteritems(shader_tests):
assert group not in profile.test_list, 'duplicate group: {}'.format(group)
# We'll end up with a list of tuples, split that into two lists
files, installedfiles = list(zip(*files))
files = list(files)
installedfiles = list(installedfiles)
# If there is only one file in the directory use a normal shader_test.
# Otherwise use a MultiShaderTest
if len(files) == 1:
group = grouptools.join(
group, os.path.basename(os.path.splitext(files[0])[0]))
profile.test_list[group] = ShaderTest.new(files[0])
profile.test_list[group] = ShaderTest.new(files[0], installedfiles[0])
else:
profile.test_list[group] = MultiShaderTest.new(files)
if all(i is None for i in installedfiles):
installedfiles = None
else:
for i, n in enumerate(installedfiles):
if n is None:
installedfiles[i] = files[i]
profile.test_list[group] = MultiShaderTest.new(files, installedfiles)
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