Skip to content
Snippets Groups Projects
Commit f0e2d13f authored by Damien George's avatar Damien George
Browse files

tests/run-tests: Simplify handling of newline in output from tests.

Now, all output has newlines converted to \n, regardless of port or
platform.
parent ed593780
No related branches found
No related tags found
No related merge requests found
...@@ -136,8 +136,6 @@ def run_micropython(pyb, args, test_file): ...@@ -136,8 +136,6 @@ def run_micropython(pyb, args, test_file):
if i_mupy >= len(lines_mupy): if i_mupy >= len(lines_mupy):
break break
output_mupy = b''.join(lines_mupy) output_mupy = b''.join(lines_mupy)
if os.name == 'nt':
output_mupy = output_mupy.replace(b'\n', b'\r\n')
else: else:
# a standard test # a standard test
...@@ -150,10 +148,13 @@ def run_micropython(pyb, args, test_file): ...@@ -150,10 +148,13 @@ def run_micropython(pyb, args, test_file):
import pyboard import pyboard
pyb.enter_raw_repl() pyb.enter_raw_repl()
try: try:
output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n') output_mupy = pyb.execfile(test_file)
except pyboard.PyboardError: except pyboard.PyboardError:
output_mupy = b'CRASH' output_mupy = b'CRASH'
# canonical form for all ports/platforms is to use \n for end-of-line
output_mupy = output_mupy.replace(b'\r\n', b'\n')
return output_mupy return output_mupy
def run_tests(pyb, tests, args): def run_tests(pyb, tests, args):
...@@ -277,8 +278,6 @@ def run_tests(pyb, tests, args): ...@@ -277,8 +278,6 @@ def run_tests(pyb, tests, args):
# expected output given by a file, so read that in # expected output given by a file, so read that in
with open(test_file_expected, 'rb') as f: with open(test_file_expected, 'rb') as f:
output_expected = f.read() output_expected = f.read()
if os.name == 'nt':
output_expected = output_expected.replace(b'\n', b'\r\n')
else: else:
# run CPython to work out expected output # run CPython to work out expected output
try: try:
...@@ -289,17 +288,16 @@ def run_tests(pyb, tests, args): ...@@ -289,17 +288,16 @@ def run_tests(pyb, tests, args):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
output_expected = b'CPYTHON3 CRASH' output_expected = b'CPYTHON3 CRASH'
# canonical form for all host platforms is to use \n for end-of-line
output_expected = output_expected.replace(b'\r\n', b'\n')
if args.write_exp: if args.write_exp:
continue continue
# run Micro Python # run Micro Python
output_mupy = run_micropython(pyb, args, test_file) output_mupy = run_micropython(pyb, args, test_file)
if os.name != 'nt':
# It may be the case that we run Windows build under Linux
# (using Wine).
output_mupy = output_mupy.replace(b'\r\n', b'\n')
if output_mupy == b'SKIP\n' or output_mupy == b'SKIP\r\n': if output_mupy == b'SKIP\n':
print("skip ", test_file) print("skip ", test_file)
skipped_tests.append(test_name) skipped_tests.append(test_name)
continue continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment