[Piglit] [PATCH 05/45] gen_uniform_initializer_tests.py: Use templates folder for templates

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


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/CMakeLists.txt                     | 16 +++++-----
 generated_tests/gen_uniform_initializer_tests.py   | 36 ++++++++++------------
 .../fs-initializer-from-const.shader_test.mako}    |  0
 .../fs-initializer-set-by-API.shader_test.mako}    |  0
 ...nitializer-set-by-other-stage.shader_test.mako} |  0
 .../fs-initializer.shader_test.mako}               |  0
 .../vs-initializer-from-const.shader_test.mako}    |  0
 .../vs-initializer-set-by-API.shader_test.mako}    |  0
 ...nitializer-set-by-other-stage.shader_test.mako} |  0
 .../vs-initializer.shader_test.mako}               |  0
 10 files changed, 24 insertions(+), 28 deletions(-)
 rename generated_tests/{uniform-initializer-templates/fs-initializer-from-const.template => templates/gen_uniform_initializer_tests/fs-initializer-from-const.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/fs-initializer-set-by-API.template => templates/gen_uniform_initializer_tests/fs-initializer-set-by-API.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/fs-initializer-set-by-other-stage.template => templates/gen_uniform_initializer_tests/fs-initializer-set-by-other-stage.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/fs-initializer.template => templates/gen_uniform_initializer_tests/fs-initializer.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/vs-initializer-from-const.template => templates/gen_uniform_initializer_tests/vs-initializer-from-const.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/vs-initializer-set-by-API.template => templates/gen_uniform_initializer_tests/vs-initializer-set-by-API.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/vs-initializer-set-by-other-stage.template => templates/gen_uniform_initializer_tests/vs-initializer-set-by-other-stage.shader_test.mako} (100%)
 rename generated_tests/{uniform-initializer-templates/vs-initializer.template => templates/gen_uniform_initializer_tests/vs-initializer.shader_test.mako} (100%)

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index 33d9f42..0bbf70f 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -48,14 +48,14 @@ piglit_make_generated_tests(
 piglit_make_generated_tests(
 	uniform-initializer_tests.list
 	gen_uniform_initializer_tests.py
-	uniform-initializer-templates/fs-initializer.template
-	uniform-initializer-templates/vs-initializer.template
-	uniform-initializer-templates/fs-initializer-from-const.template
-	uniform-initializer-templates/vs-initializer-from-const.template
-	uniform-initializer-templates/fs-initializer-set-by-API.template
-	uniform-initializer-templates/vs-initializer-set-by-API.template
-	uniform-initializer-templates/fs-initializer-set-by-other-stage.template
-	uniform-initializer-templates/vs-initializer-set-by-other-stage.template
+	templates/gen_uniform_initializer_tests/fs-initializer.shader_test.mako
+	templates/gen_uniform_initializer_tests/vs-initializer.shader_test.mako
+	templates/gen_uniform_initializer_tests/fs-initializer-from-const.shader_test.mako
+	templates/gen_uniform_initializer_tests/vs-initializer-from-const.shader_test.mako
+	templates/gen_uniform_initializer_tests/fs-initializer-set-by-API.shader_test.mako
+	templates/gen_uniform_initializer_tests/vs-initializer-set-by-API.shader_test.mako
+	templates/gen_uniform_initializer_tests/fs-initializer-set-by-other-stage.shader_test.mako
+	templates/gen_uniform_initializer_tests/vs-initializer-set-by-other-stage.shader_test.mako
 	)
 piglit_make_generated_tests(
 	builtin_cl_int_tests.list
diff --git a/generated_tests/gen_uniform_initializer_tests.py b/generated_tests/gen_uniform_initializer_tests.py
index 0fbd986..d26c0fd 100644
--- a/generated_tests/gen_uniform_initializer_tests.py
+++ b/generated_tests/gen_uniform_initializer_tests.py
@@ -1,6 +1,6 @@
 # coding=utf-8
 #
-# Copyright © 2012 Intel Corporation
+# Copyright © 2012, 2014 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,10 @@
 
 import os
 import os.path
-from mako.template import Template
+
+from templates import template_dir
+
+TEMPLATES = template_dir(os.path.splitext(os.path.basename(__file__))[0])
 
 
 def open_src_file(filename):
@@ -54,12 +57,8 @@ def get_value(type, idx):
 def generate_tests(type_list, base_name, major, minor):
     for target in ("vs", "fs"):
         for t in all_templates:
-            template_file_name = (
-                "uniform-initializer-templates/"
-                "{0}-initializer{1}.template".format(target, t))
-            f = open_src_file(template_file_name)
-            template = f.read()
-            f.close()
+            template = TEMPLATES.get_template(
+                "{0}-initializer{1}.shader_test.mako".format(target, t))
 
             test_file_name = os.path.join(
                 'spec',
@@ -107,20 +106,17 @@ def generate_tests(type_list, base_name, major, minor):
                 j = j + 1
 
             f = open(test_file_name, "w")
-            f.write(Template(template).render(type_list=test_vectors,
-                                              api_types=api_vectors,
-                                              major=major,
-                                              minor=minor))
+            f.write(template.render(type_list=test_vectors,
+                                    api_types=api_vectors,
+                                    major=major,
+                                    minor=minor))
             f.close()
 
 
 def generate_array_tests(type_list, base_name, major, minor):
     for target in ("vs", "fs"):
-        template_file_name = \
-            "uniform-initializer-templates/{0}-initializer.template".format(target)
-        f = open_src_file(template_file_name)
-        template = f.read()
-        f.close()
+        template = TEMPLATES.get_template(
+            '{0}-initializer.shader_test.mako'.format(target))
 
         test_file_name = os.path.join(
             'spec',
@@ -158,9 +154,9 @@ def generate_array_tests(type_list, base_name, major, minor):
             j = j + 1
 
         f = open(test_file_name, "w")
-        f.write(Template(template).render(type_list=test_vectors,
-                                          major=major,
-                                          minor=minor))
+        f.write(template.render(type_list=test_vectors,
+                                major=major,
+                                minor=minor))
         f.close()
 
 # These are a set of pseudo random values used by the number sequence
diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template b/generated_tests/templates/gen_uniform_initializer_tests/fs-initializer-from-const.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/fs-initializer-from-const.template
rename to generated_tests/templates/gen_uniform_initializer_tests/fs-initializer-from-const.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template b/generated_tests/templates/gen_uniform_initializer_tests/fs-initializer-set-by-API.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template
rename to generated_tests/templates/gen_uniform_initializer_tests/fs-initializer-set-by-API.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-set-by-other-stage.template b/generated_tests/templates/gen_uniform_initializer_tests/fs-initializer-set-by-other-stage.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/fs-initializer-set-by-other-stage.template
rename to generated_tests/templates/gen_uniform_initializer_tests/fs-initializer-set-by-other-stage.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/fs-initializer.template b/generated_tests/templates/gen_uniform_initializer_tests/fs-initializer.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/fs-initializer.template
rename to generated_tests/templates/gen_uniform_initializer_tests/fs-initializer.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template b/generated_tests/templates/gen_uniform_initializer_tests/vs-initializer-from-const.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/vs-initializer-from-const.template
rename to generated_tests/templates/gen_uniform_initializer_tests/vs-initializer-from-const.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template b/generated_tests/templates/gen_uniform_initializer_tests/vs-initializer-set-by-API.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template
rename to generated_tests/templates/gen_uniform_initializer_tests/vs-initializer-set-by-API.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-set-by-other-stage.template b/generated_tests/templates/gen_uniform_initializer_tests/vs-initializer-set-by-other-stage.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/vs-initializer-set-by-other-stage.template
rename to generated_tests/templates/gen_uniform_initializer_tests/vs-initializer-set-by-other-stage.shader_test.mako
diff --git a/generated_tests/uniform-initializer-templates/vs-initializer.template b/generated_tests/templates/gen_uniform_initializer_tests/vs-initializer.shader_test.mako
similarity index 100%
rename from generated_tests/uniform-initializer-templates/vs-initializer.template
rename to generated_tests/templates/gen_uniform_initializer_tests/vs-initializer.shader_test.mako
-- 
2.1.3



More information about the Piglit mailing list