Skip to content

Commit 5ffa37c

Browse files
committed
[test] Remove decode_output argument to shared.run_process. NFC
1 parent bc55110 commit 5ffa37c

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

scripts/test/shared.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,11 @@ def remove_readonly_and_try_again(func, path, exc_info):
301301
pass
302302

303303

304-
def run_process(cmd, check=True, input=None, decode_output=True, *args, **kwargs):
305-
if input and type(input) is str:
306-
input = bytes(input, 'utf-8')
307-
ret = subprocess.run(cmd, *args, check=check, input=input, **kwargs)
308-
if decode_output and ret.stdout is not None:
309-
ret.stdout = ret.stdout.decode('utf-8')
310-
if ret.stderr is not None:
311-
ret.stderr = ret.stderr.decode('utf-8')
312-
return ret
304+
def run_process(cmd, check=True, text=True, *args, **kw):
305+
"""Trivial wrapper around subprocess.run that defaults to check=True and
306+
text=True
307+
"""
308+
return subprocess.run(cmd, check=check, text=text, *args, **kw)
313309

314310

315311
def fail_with_error(msg):

test/unit/test_features.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,19 @@ def test_explicit_detect_features(self):
421421
opts=['-mvp', '--detect-features', '--enable-simd'])
422422

423423
def test_emit_all_features(self):
424+
# We use text=False in this test because we pass binary modules via
425+
# stdin and stdout.
424426
p = shared.run_process(shared.WASM_OPT +
425427
['--emit-target-features', '-all', '-o', '-'],
426-
input="(module)", check=False,
427-
capture_output=True, decode_output=False)
428+
input=b"(module)", check=False, text=False,
429+
capture_output=True)
428430
self.assertEqual(p.returncode, 0)
429431
p2 = shared.run_process(shared.WASM_OPT +
430432
['--print-features', '-o', os.devnull],
431-
input=p.stdout, check=False,
433+
input=p.stdout, text=False, check=False,
432434
capture_output=True)
433435
self.assertEqual(p2.returncode, 0)
436+
output = p2.stdout.debug('utf-8')
434437
self.assertEqual([
435438
'--enable-threads',
436439
'--enable-mutable-globals',
@@ -454,4 +457,4 @@ def test_emit_all_features(self):
454457
'--enable-bulk-memory-opt',
455458
'--enable-call-indirect-overlong',
456459
'--enable-custom-descriptors',
457-
], p2.stdout.splitlines())
460+
], output.splitlines())

0 commit comments

Comments
 (0)