[Piglit] [PATCH 21/34] gen_shader_bit_encoding_tests.py: python 2/3 hybridize
Dylan Baker
baker.dylan.c at gmail.com
Fri Feb 20 18:18:08 PST 2015
This requires modifications to the mako template and to the generator
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
generated_tests/gen_shader_bit_encoding_tests.py | 10 ++++++----
.../gen_shader_bit_encoding_tests/template.shader_test.mako | 3 ++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/generated_tests/gen_shader_bit_encoding_tests.py b/generated_tests/gen_shader_bit_encoding_tests.py
index 4656755..5eda4b4 100644
--- a/generated_tests/gen_shader_bit_encoding_tests.py
+++ b/generated_tests/gen_shader_bit_encoding_tests.py
@@ -26,6 +26,8 @@ import struct
import os
from operator import neg
+import six
+
from templates import template_file
from modules import utils
@@ -134,7 +136,7 @@ REQUIREMENTS = {
def main():
"""main function."""
# pylint: disable=line-too-long
- for api, requirement in REQUIREMENTS.iteritems():
+ for api, requirement in six.iteritems(REQUIREMENTS):
version = requirement['version']
extensions = [requirement['extension']] if requirement['extension'] else []
@@ -142,9 +144,9 @@ def main():
'built-in-functions')
utils.safe_makedirs(dirname)
- for func, attrib in FUNCS.iteritems():
+ for func, attrib in six.iteritems(FUNCS):
for execution_stage in ('vs', 'fs'):
- for in_modifier_func, modifier_func in MODIFIER_FUNCS.iteritems():
+ for in_modifier_func, modifier_func in six.iteritems(MODIFIER_FUNCS):
# Modifying the sign of an unsigned number doesn't make sense.
if func == 'uintBitsToFloat' and in_modifier_func != '':
continue
@@ -162,7 +164,7 @@ def main():
in_modifier_func = '-abs'
with open(filename, 'w') as f:
- f.write(TEMPLATE.render(
+ f.write(TEMPLATE.render_unicode(
version=version,
extensions=extensions,
execution_stage=execution_stage,
diff --git a/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako b/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako
index 83eb567..a7f49d9 100644
--- a/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako
+++ b/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako
@@ -1,3 +1,4 @@
+<%! import six %>
[require]
GLSL >= ${version}
% for extension in extensions:
@@ -73,7 +74,7 @@ vertex/float/2
-1.0 1.0
[test]
-% for name, data in sorted(test_data.iteritems()):
+% for name, data in sorted(six.iteritems(test_data)):
% if name == '-0.0' and in_modifier_func != '' and func == 'intBitsToFloat':
# ${in_modifier_func}(INT_MIN) doesn't fit in a 32-bit int. Cannot test.
% else:
--
2.3.0
More information about the Piglit
mailing list