[Piglit] [PATCH 18/24] gen_const_builtin_equal_tests.py: put template in templates dir

Dylan Baker baker.dylan.c at gmail.com
Mon Nov 24 09:58:18 PST 2014


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 generated_tests/CMakeLists.txt                     |  4 ++-
 generated_tests/gen_const_builtin_equal_tests.py   | 29 ++++------------------
 .../template.shader_test.mako                      | 20 +++++++++++++++
 3 files changed, 28 insertions(+), 25 deletions(-)
 create mode 100644 generated_tests/templates/gen_const_builtin_equal_tests/template.shader_test.mako

diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index ff8eb88..2910a0a 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -32,7 +32,9 @@ piglit_make_generated_tests(
 	builtin_function.py)
 piglit_make_generated_tests(
 	const_builtin_equal_tests.list
-	gen_const_builtin_equal_tests.py)
+	gen_const_builtin_equal_tests.py
+	templates/gen_const_builtin_equal_tests/template.shader_test.mako
+	)
 piglit_make_generated_tests(
 	interpolation_tests.list
 	gen_interpolation_tests.py)
diff --git a/generated_tests/gen_const_builtin_equal_tests.py b/generated_tests/gen_const_builtin_equal_tests.py
index f002230..eb2856c 100644
--- a/generated_tests/gen_const_builtin_equal_tests.py
+++ b/generated_tests/gen_const_builtin_equal_tests.py
@@ -23,30 +23,11 @@
 from __future__ import print_function
 import re
 import os
-import textwrap
-import mako.template
-
-TEMPLATE = mako.template.Template(textwrap.dedent("""
-    [require]
-    GLSL >= 1.20
-
-    [vertex shader]
-    void main()
-    {
-      gl_Position = gl_Vertex;
-    }
-
-    [fragment shader]
-    void main()
-    {
-      const ${expected.split('(')[0]} res = ${func}(${input[0]}, ${input[1]});
-      gl_FragColor = (res == ${expected})
-        ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
-    }
-
-    [test]
-    draw rect -1 -1 2 2
-    probe all rgb 0.0 1.0 0.0"""))
+
+from templates import template_file
+
+TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
+                         'template.shader_test.mako')
 
 TEST_VECTORS = [
     ["vec2(3.0, 3.14)",
diff --git a/generated_tests/templates/gen_const_builtin_equal_tests/template.shader_test.mako b/generated_tests/templates/gen_const_builtin_equal_tests/template.shader_test.mako
new file mode 100644
index 0000000..1126235
--- /dev/null
+++ b/generated_tests/templates/gen_const_builtin_equal_tests/template.shader_test.mako
@@ -0,0 +1,20 @@
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+void main()
+{
+  const ${expected.split('(')[0]} res = ${func}(${input[0]}, ${input[1]});
+  gl_FragColor = (res == ${expected})
+    ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgb 0.0 1.0 0.0
-- 
2.1.3



More information about the Piglit mailing list