diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-01-14 12:18:34 -0800 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2015-02-23 17:32:51 -0800 |
commit | 3d334300061e90de3ed6a432754cbbe6402c244d (patch) | |
tree | ce40cfc54cf5b1825d41cafa20490c12676b2ca6 /framework/test/shader_test.py | |
parent | 4117da821bae16707e40040adca9024fc6cf07c2 (diff) |
shader_test.py: use os.walk in add_shader_test_Dir
Python's os module provides a wonderful generator function for walking
directory trees, os.walk. By using os.walk with grouptools.join we don't
need to use a recursive function to add shader tests.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework/test/shader_test.py')
-rw-r--r-- | framework/test/shader_test.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py index 16d813ff7..5fd2de79c 100644 --- a/framework/test/shader_test.py +++ b/framework/test/shader_test.py @@ -25,10 +25,10 @@ from __future__ import print_function, absolute_import import os -import os.path as path import re from .piglit_test import PiglitBaseTest +from framework import grouptools __all__ = [ 'ShaderTest', @@ -100,14 +100,15 @@ class ShaderTestParserException(Exception): pass -def add_shader_test_dir(group, dirpath): +def add_shader_test_dir(group, startdir): """Add all shader tests in a directory to the given group.""" - for filename in os.listdir(dirpath): - filepath = path.join(dirpath, filename) - if path.isdir(filepath): - add_shader_test_dir(group[filename], filepath) - else: + for dirpath, _, filenames in os.walk(startdir): + for filename in filenames: testname, ext = os.path.splitext(filename) if ext != '.shader_test': continue - group[testname] = ShaderTest(filepath) + + lgroup = grouptools.join( + grouptools.from_path(os.path.relpath(dirpath, startdir)), + testname) + group[lgroup] = ShaderTest(os.path.join(dirpath, filename)) |