summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl
diff options
context:
space:
mode:
authorDylan Baker <[email protected]>2018-08-16 14:17:24 -0700
committerDylan Baker <[email protected]>2018-08-22 08:41:01 -0700
commit477d4b9960ae8b7524806a9dff1d91b0546ec0f2 (patch)
tree7b721cbc9ae31e392bd688f6ddc9412e39fa9e64 /src/compiler/glsl
parent6ea5718318834cb3b7972d1e38ddd7bbeff36f08 (diff)
compiler/glsl/tests: Make tests python3 safe
v2: - explicitly decode the output of subprocesses - handle bytes and string types consistently rather than relying on python 2's coercion for bytes and ignoring them in python 3 v3: - explicitly set encode as well as decode - python 2.7 and 3.x `bytes` instead of defining an alias Reviewed-by: Mathieu Bridon <[email protected]>
Diffstat (limited to 'src/compiler/glsl')
-rw-r--r--src/compiler/glsl/tests/lower_jump_cases.py2
-rwxr-xr-xsrc/compiler/glsl/tests/optimization_test.py6
-rw-r--r--src/compiler/glsl/tests/sexps.py11
3 files changed, 14 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..b3147ed08fc 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('utf-8'))
+ out = out.decode('utf-8')
+ err = err.decode('utf-8')
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..7939b42f9a2 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):
+ STRING_TYPE = str
+else:
+ STRING_TYPE = 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, (STRING_TYPE, bytes)):
raise Exception('Not a sexp: {0!r}'.format(sexp))
def parse_sexp(sexp):
@@ -70,8 +75,10 @@ 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, STRING_TYPE):
return sexp
+ if isinstance(sexp, bytes):
+ return sexp.encode('utf-8')
assert isinstance(sexp, list)
result = ''
for s in sexp: