[Piglit] [PATCH 09/12] glsl_parser_test.py: simplify and cleanup add_glsl_parser_dir

Dylan Baker baker.dylan.c at gmail.com
Tue Feb 11 18:11:14 PST 2014


This removes some unnecessary code, and fixes a few pylint warnings.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/glsl_parser_test.py | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index 40271b0..2b413c4 100644
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -50,22 +50,15 @@ def import_glsl_parser_tests(group, basepath, subdirectories):
     is called and the file 'a/b1/c/d.frag' exists, then the test is
     registered into the group as ``group['b1/c/d.frag']``.
     """
-    for d in subdirectories:
-        walk_dir = path.join(basepath, d)
-        for (dirpath, dirnames, filenames) in os.walk(walk_dir):
-            # Ignore dirnames.
-            for f in filenames:
-                # Add f as a test if its file extension is good.
-                ext = f.rsplit('.')[-1]
-                if ext in ['vert', 'geom', 'frag', 'comp']:
-                    filepath = path.join(dirpath, f)
-                    # testname := filepath relative to
-                    # basepath.
-                    testname = os.path.relpath(filepath, basepath)
-                    if os.path.sep != '/':
-                        testname = testname.replace(os.path.sep, '/', -1)
-                    assert isinstance(testname, basestring)
-                    add_glsl_parser_test(group, filepath, testname)
+    for test_dir in subdirectories:
+        walk_dir = path.join(basepath, test_dir)
+        for (dirpath, _, filenames) in os.walk(walk_dir):
+            for test_file in filenames:
+                ext = os.path.splitext(test_file)[1]
+                if ext in ['.vert', '.geom', '.frag', '.comp']:
+                    filepath = path.join(dirpath, test_file)
+                    add_glsl_parser_test(group, filepath, 
+                                         os.path.relpath(filepath, basepath))
 
 
 def glsl_parser_test(filepath):
-- 
1.8.5.4



More information about the Piglit mailing list