summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2011-07-30 11:49:30 -0700
committerPaul Berry <stereotype441@gmail.com>2011-08-11 13:13:02 -0700
commit76c27e1327fa6e28afeb7f5bb82750913b25cbbe (patch)
treebbc0e0eb8a02c2b4d9c20c49de32ca226a23cabc /framework
parent3599bede47a9bcd36e0be596c7e19e6232e22cd0 (diff)
Fix import_glsl_parser_tests' dependency on the number of dirs in basepath.
To figure out where a test file belongs in the test hierarchy, import_glsl_parser_tests has to determine the test file's path relative to the "basepath" argument. Before this patch, it worked out the relative path by dropping the first three directories from the test file's path. This worked because import_glsl_parser_tests was always called with a basepath that contained exactly three directory names, e.g. "./spec/glsl-1.00". But it was a fragile assumption. This patch changes import_glsl_parser_tests so that it uses os.path.relpath() to work out the relative path. I've also taken the liberty of fixing a typo in the docstring explaining how basebath is used, and I've changed "assert(type(testname) is str)" to "assert isinstance(testname, basestring)", which works properly with Unicode. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'framework')
-rwxr-xr-xframework/glsl_parser_test.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
index da8ff62b..118df136 100755
--- a/framework/glsl_parser_test.py
+++ b/framework/glsl_parser_test.py
@@ -58,7 +58,7 @@ def import_glsl_parser_tests(group, basepath, subdirectories):
the shader source file's path relative to ``basepath``. For example,
if::
import_glsl_parser_tests(group, 'a', ['b1', 'b2'])
- is called and the file 'a/b/c/d.frag' exists, then the test is
+ 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:
@@ -70,10 +70,11 @@ def import_glsl_parser_tests(group, basepath, subdirectories):
ext = f.rsplit('.')[-1]
if ext in ['vert', 'geom', 'frag']:
filepath = path.join(dirpath, f)
- # testname := filepath with initial
- # three directories removed.
- testname = '/'.join(filepath.split(os.sep)[3:])
- assert(type(testname) is str)
+ # testname := filepath relative to
+ # basepath.
+ testname = os.path.relpath(
+ filepath, basepath)
+ assert isinstance(testname, basestring)
add_glsl_parser_test(
group,
filepath,