[Piglit] [PATCH 31/45] gen_const_builtin_equal_tests.py: us os.path.join for directory names

Dylan Baker baker.dylan.c at gmail.com
Wed Nov 12 15:46:13 PST 2014


This makes the test generators more OS agnostic.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/gen_const_builtin_equal_tests.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/generated_tests/gen_const_builtin_equal_tests.py b/generated_tests/gen_const_builtin_equal_tests.py
index ed0b006..f002230 100644
--- a/generated_tests/gen_const_builtin_equal_tests.py
+++ b/generated_tests/gen_const_builtin_equal_tests.py
@@ -90,15 +90,17 @@ TEST_VECTORS = [
 
 def main():
     """ Main function """
-    try:
-        os.makedirs('spec/glsl-1.20/execution/built-in-functions')
-    except OSError:
-        pass
+    dirname = os.path.join('spec', 'glsl-1.20', 'execution',
+                           'built-in-functions')
+    if not os.path.exists(dirname):
+        os.makedirs(dirname)
 
     for test_id, x in enumerate(TEST_VECTORS, start=2):
         # make equal tests
-        name = ("spec/glsl-1.20/execution/built-in-functions/"
-                "glsl-const-builtin-equal-{0:02d}.shader_test".format(test_id))
+        name = os.path.join(
+            dirname,
+            "glsl-const-builtin-equal-{0:02d}.shader_test".format(test_id))
+
         print(name)
 
         with open(name, 'w') as f:
@@ -106,9 +108,9 @@ def main():
                 func='equal', input=x[0:2], expected=x[2]))
 
         # make notEqual tests
-        name = ("spec/glsl-1.20/execution/built-in-functions/"
-                "glsl-const-builtin-notEqual-{0:02d}.shader_test".format(
-                    test_id))
+        name = os.path.join(
+            dirname,
+            "glsl-const-builtin-notEqual-{0:02d}.shader_test".format(test_id))
 
         # When generating the notEqual tests, each of the values in the
         # expected result vector need to be inverted
@@ -122,5 +124,6 @@ def main():
             f.write(TEMPLATE.render_unicode(
                 func='notEqual', input=x[0:2], expected=expected))
 
+
 if __name__ == "__main__":
     main()
-- 
2.1.3



More information about the Piglit mailing list