2 """A profile that runs only ShaderTest instances."""
7 from framework
.options
import OPTIONS
8 from framework
import grouptools
9 from framework
.profile
import TestProfile
10 from framework
.test
.shader_test
import ShaderTest
, MultiShaderTest
11 from .py_modules
.constants
import GENERATED_TESTS_DIR
, TESTS_DIR
15 profile
= TestProfile()
17 shader_tests
= collections
.defaultdict(list)
19 # Find and add all shader tests.
20 basepath
= os
.path
.normpath(os
.path
.join(TESTS_DIR
, '..'))
21 gen_basepath
= os
.path
.relpath(os
.path
.join(GENERATED_TESTS_DIR
, '..'), basepath
)
23 for basedir
in [TESTS_DIR
, GENERATED_TESTS_DIR
]:
24 isgenerated
= basedir
== GENERATED_TESTS_DIR
25 for dirpath
, _
, filenames
in os
.walk(basedir
):
26 groupname
= grouptools
.from_path(os
.path
.relpath(dirpath
, basedir
))
27 for filename
in filenames
:
28 testname
, ext
= os
.path
.splitext(filename
)
29 if ext
== '.shader_test':
30 dirname
= os
.path
.relpath(dirpath
, basepath
)
31 filepath
= os
.path
.join(dirname
, filename
)
33 installpath
= os
.path
.relpath(filepath
, gen_basepath
)
37 if OPTIONS
.process_isolation
:
38 test
= ShaderTest
.new(filepath
, installpath
)
40 shader_tests
[groupname
].append((filepath
, installpath
))
45 group
= grouptools
.join(groupname
, testname
)
46 assert group
not in profile
.test_list
, group
48 profile
.test_list
[group
] = test
50 # Because we need to handle duplicate group names in TESTS and GENERATED_TESTS
51 # this dictionary is constructed, then added to the actual test dictionary.
52 for group
, files
in shader_tests
.items():
53 assert group
not in profile
.test_list
, 'duplicate group: {}'.format(group
)
55 # This makes the xml output reproducible, as os.walk() order is random
57 # We'll end up with a list of tuples, split that into two list
58 files
, installedfiles
= list(zip(*files
))
60 installedfiles
= list(installedfiles
)
62 # If there is only one file in the directory use a normal shader_test.
63 # Otherwise use a MultiShaderTest
65 group
= grouptools
.join(
66 group
, os
.path
.basename(os
.path
.splitext(files
[0])[0]))
67 profile
.test_list
[group
] = ShaderTest
.new(files
[0], installedfiles
[0])
69 if all(i
is None for i
in installedfiles
):
72 for i
, n
in enumerate(installedfiles
):
74 installedfiles
[i
] = files
[i
]
76 profile
.test_list
[group
] = MultiShaderTest
.new(files
, installedfiles
)