summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtest/gen-wasm.py10
-rwxr-xr-xtest/run-tests.py19
-rwxr-xr-xtest/update-spec-tests.py5
-rw-r--r--test/utils.py7
4 files changed, 25 insertions, 16 deletions
diff --git a/test/gen-wasm.py b/test/gen-wasm.py
index e0201e0c..325ebee9 100755
--- a/test/gen-wasm.py
+++ b/test/gen-wasm.py
@@ -15,8 +15,8 @@
# limitations under the License.
#
+from __future__ import print_function
import argparse
-import cStringIO
import os
import struct
import sys
@@ -294,7 +294,7 @@ def t_newline(t):
t.lexer.lineno += len(t.value)
def t_error(t):
- print "Illegal character '%s'" % t.value[0]
+ print("Illegal character '%s'" % t.value[0])
t.lexer.skip(1)
lexer = lex.lex()
@@ -426,7 +426,7 @@ def p_data_empty(p):
p[0] = []
def p_error(p):
- print '%d: syntax error, %s' % (p.lineno, p)
+ print('%d: syntax error, %s' % (p.lineno, p))
parser = yacc.yacc(tabmodule='gen_wasm', debugfile='gen_wasm_debug.txt',
outputdir=OUT_DIR)
@@ -437,8 +437,8 @@ def Run(input_file_name):
with open(input_file_name) as input_file:
input_data = input_file.read()
data = parser.parse(input_data)
- # convert to string
- data = ''.join(chr(x) for x in data)
+ # convert to bytes
+ data = bytearray(data)
return data
def main(args):
diff --git a/test/run-tests.py b/test/run-tests.py
index 47e4c8fa..216ff8f9 100755
--- a/test/run-tests.py
+++ b/test/run-tests.py
@@ -15,12 +15,17 @@
# limitations under the License.
#
+from __future__ import print_function
import argparse
import difflib
import fnmatch
import multiprocessing
import os
-import Queue
+try:
+ import Queue
+except ImportError:
+ # Python3?
+ import queue as Queue
import re
import shlex
import shutil
@@ -260,7 +265,7 @@ class TestInfo(object):
if not value in TOOLS:
raise Error('Unknown tool: %s' % value)
self.tool = value
- for tool_key, tool_value in TOOLS[value].iteritems():
+ for tool_key, tool_value in TOOLS[value].items():
self.ParseDirective(tool_key, tool_value)
else:
raise Error('Unknown directive: %s' % key)
@@ -367,8 +372,8 @@ class TestInfo(object):
with open(self.input_filename, 'rb') as input_filename:
file_.write(input_filename.read())
else:
- file_.write('\n' * self.header.count('\n'))
- file_.write(self.input_)
+ file_.write(('\n' * self.header.count('\n')).encode('ascii'))
+ file_.write(self.input_.encode('ascii'))
file_.flush()
file_.close()
@@ -689,10 +694,10 @@ def main(args):
if options.list:
for test_name in test_names:
- print test_name
+ print(test_name)
return 0
if not test_names:
- print 'no tests match that filter'
+ print('no tests match that filter')
return 1
if options.exe_dir:
@@ -746,7 +751,7 @@ def main(args):
else:
RunSingleProcess(infos_to_run, status, options, variables)
except:
- print '\nInterrupted testing\n'
+ print('\nInterrupted testing\n')
finally:
if out_dir_is_temp:
shutil.rmtree(out_dir)
diff --git a/test/update-spec-tests.py b/test/update-spec-tests.py
index 803878fc..39fb32be 100755
--- a/test/update-spec-tests.py
+++ b/test/update-spec-tests.py
@@ -15,6 +15,7 @@
# limitations under the License.
#
+from __future__ import print_function
import argparse
import os
import sys
@@ -47,7 +48,7 @@ def main(args):
for removed_test_name in spec_tests - testsuite_tests:
test_filename = os.path.join(SPEC_TEST_DIR, removed_test_name + '.txt')
if options.verbose:
- print 'Removing %s' % test_filename
+ print('Removing %s' % test_filename)
os.remove(test_filename)
for added_test_name in testsuite_tests - spec_tests:
@@ -55,7 +56,7 @@ def main(args):
added_test_name + '.wast')
test_filename = os.path.join(SPEC_TEST_DIR, added_test_name + '.txt')
if options.verbose:
- print 'Adding %s' % test_filename
+ print('Adding %s' % test_filename)
with open(test_filename, 'w') as f:
if added_test_name.endswith('.fail'):
f.write(';;; ERROR: 1\n')
diff --git a/test/utils.py b/test/utils.py
index a9c8dce4..97d915ce 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -15,6 +15,7 @@
# limitations under the License.
#
+from __future__ import print_function
import contextlib
import os
import shutil
@@ -47,7 +48,7 @@ class Executable(object):
cmd = [self.exe] + self.before_args + list(args) + self.after_args
cmd_str = ' '.join(cmd)
if self.verbose:
- print cmd_str
+ print(cmd_str)
err_cmd_str = cmd_str.replace('.exe', '')
if not self.error_cmdline:
@@ -61,6 +62,8 @@ class Executable(object):
stderr=subprocess.PIPE,
**kwargs)
stdout, stderr = process.communicate()
+ stdout = stdout.decode('ascii')
+ stderr = stderr.decode('ascii')
if self.clean_stdout:
stdout = self.clean_stdout(stdout)
if self.clean_stderr:
@@ -92,7 +95,7 @@ class Executable(object):
self.after_args.append(arg)
def AppendOptionalArgs(self, option_dict):
- for option, value in option_dict.iteritems():
+ for option, value in option_dict.items():
if value:
self.AppendArg(option)