[Mesa-dev] [PATCH 1/2] compiler/glsl/tests: Make tests python3 safe
Dylan Baker
dylan at pnwbakers.com
Thu Aug 16 21:21:06 UTC 2018
---
I didn't see any patches from anyone else, so I wrote some real quick. Please
point to them if other patches already exist.
src/compiler/glsl/tests/lower_jump_cases.py | 2 +-
src/compiler/glsl/tests/optimization_test.py | 6 ++++--
src/compiler/glsl/tests/sexps.py | 9 +++++++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/compiler/glsl/tests/lower_jump_cases.py b/src/compiler/glsl/tests/lower_jump_cases.py
index b50ab734798..1977f3a9b4f 100644
--- a/src/compiler/glsl/tests/lower_jump_cases.py
+++ b/src/compiler/glsl/tests/lower_jump_cases.py
@@ -54,7 +54,7 @@ def make_test_case(f_name, ret_type, body):
else:
make_declarations(s, already_declared)
make_declarations(body)
- return declarations.values() + \
+ return list(declarations.values()) + \
[['function', f_name, ['signature', ret_type, ['parameters'], body]]]
diff --git a/src/compiler/glsl/tests/optimization_test.py b/src/compiler/glsl/tests/optimization_test.py
index 577d2dfc20f..f40d0cee6bd 100755
--- a/src/compiler/glsl/tests/optimization_test.py
+++ b/src/compiler/glsl/tests/optimization_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
# encoding=utf-8
# Copyright © 2018 Intel Corporation
@@ -71,7 +71,9 @@ def main():
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
- out, err = proc.communicate(source)
+ out, err = proc.communicate(source.encode())
+ out = out.decode()
+ err = err.decode()
if err:
print('FAIL')
print('Unexpected output on stderr: {}'.format(err),
diff --git a/src/compiler/glsl/tests/sexps.py b/src/compiler/glsl/tests/sexps.py
index a714af8d236..b69d3a5e5d7 100644
--- a/src/compiler/glsl/tests/sexps.py
+++ b/src/compiler/glsl/tests/sexps.py
@@ -28,6 +28,11 @@
# as ['constant', 'float', ['1.000000']].
import re
+import sys
+if sys.version_info >= (3, 0, 0):
+ STRINGS = str
+else:
+ STRINGS = (str, unicode)
def check_sexp(sexp):
"""Verify that the argument is a proper sexp.
@@ -39,7 +44,7 @@ def check_sexp(sexp):
if isinstance(sexp, list):
for s in sexp:
check_sexp(s)
- elif not isinstance(sexp, basestring):
+ elif not isinstance(sexp, STRINGS):
raise Exception('Not a sexp: {0!r}'.format(sexp))
def parse_sexp(sexp):
@@ -70,7 +75,7 @@ def sexp_to_string(sexp):
"""Convert a sexp, represented as nested lists containing strings,
into a single string of the form parseable by mesa.
"""
- if isinstance(sexp, basestring):
+ if isinstance(sexp, STRINGS):
return sexp
assert isinstance(sexp, list)
result = ''
--
2.18.0
More information about the mesa-dev
mailing list