Skip to content

Commit f0e2d13

Browse files
committed
tests/run-tests: Simplify handling of newline in output from tests.
Now, all output has newlines converted to \n, regardless of port or platform.
1 parent ed59378 commit f0e2d13

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

tests/run-tests

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ def run_micropython(pyb, args, test_file):
136136
if i_mupy >= len(lines_mupy):
137137
break
138138
output_mupy = b''.join(lines_mupy)
139-
if os.name == 'nt':
140-
output_mupy = output_mupy.replace(b'\n', b'\r\n')
141139

142140
else:
143141
# a standard test
@@ -150,10 +148,13 @@ def run_micropython(pyb, args, test_file):
150148
import pyboard
151149
pyb.enter_raw_repl()
152150
try:
153-
output_mupy = pyb.execfile(test_file).replace(b'\r\n', b'\n')
151+
output_mupy = pyb.execfile(test_file)
154152
except pyboard.PyboardError:
155153
output_mupy = b'CRASH'
156154

155+
# canonical form for all ports/platforms is to use \n for end-of-line
156+
output_mupy = output_mupy.replace(b'\r\n', b'\n')
157+
157158
return output_mupy
158159

159160
def run_tests(pyb, tests, args):
@@ -277,8 +278,6 @@ def run_tests(pyb, tests, args):
277278
# expected output given by a file, so read that in
278279
with open(test_file_expected, 'rb') as f:
279280
output_expected = f.read()
280-
if os.name == 'nt':
281-
output_expected = output_expected.replace(b'\n', b'\r\n')
282281
else:
283282
# run CPython to work out expected output
284283
try:
@@ -289,17 +288,16 @@ def run_tests(pyb, tests, args):
289288
except subprocess.CalledProcessError:
290289
output_expected = b'CPYTHON3 CRASH'
291290

291+
# canonical form for all host platforms is to use \n for end-of-line
292+
output_expected = output_expected.replace(b'\r\n', b'\n')
293+
292294
if args.write_exp:
293295
continue
294296

295297
# run Micro Python
296298
output_mupy = run_micropython(pyb, args, test_file)
297-
if os.name != 'nt':
298-
# It may be the case that we run Windows build under Linux
299-
# (using Wine).
300-
output_mupy = output_mupy.replace(b'\r\n', b'\n')
301299

302-
if output_mupy == b'SKIP\n' or output_mupy == b'SKIP\r\n':
300+
if output_mupy == b'SKIP\n':
303301
print("skip ", test_file)
304302
skipped_tests.append(test_name)
305303
continue

0 commit comments

Comments
 (0)