Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,11 @@ def remove_readonly_and_try_again(func, path, exc_info):
pass


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


def fail_with_error(msg):
Expand Down
11 changes: 7 additions & 4 deletions test/unit/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,16 +421,19 @@ def test_explicit_detect_features(self):
opts=['-mvp', '--detect-features', '--enable-simd'])

def test_emit_all_features(self):
# We use text=False in this test because we pass binary modules via
# stdin and stdout.
p = shared.run_process(shared.WASM_OPT +
['--emit-target-features', '-all', '-o', '-'],
input="(module)", check=False,
capture_output=True, decode_output=False)
input=b"(module)", check=False, text=False,
capture_output=True)
self.assertEqual(p.returncode, 0)
p2 = shared.run_process(shared.WASM_OPT +
['--print-features', '-o', os.devnull],
input=p.stdout, check=False,
input=p.stdout, text=False, check=False,
capture_output=True)
self.assertEqual(p2.returncode, 0)
output = p2.stdout.debug('utf-8')
self.assertEqual([
'--enable-threads',
'--enable-mutable-globals',
Expand All @@ -454,4 +457,4 @@ def test_emit_all_features(self):
'--enable-bulk-memory-opt',
'--enable-call-indirect-overlong',
'--enable-custom-descriptors',
], p2.stdout.splitlines())
], output.splitlines())
Loading