Skip to content
Merged
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
2 changes: 1 addition & 1 deletion check.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def run_version_tests():
changelog_version = get_changelog_version()
for e in executables:
print('.. %s --version' % e)
proc = subprocess.run([e, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
proc = subprocess.run([e, '--version'], capture_output=True, text=True)
assert len(proc.stderr) == 0, 'Expected no stderr, got:\n%s' % proc.stderr
out = proc.stdout
assert os.path.basename(e).replace('.exe', '') in out, 'Expected version to contain program name, got:\n%s' % out
Expand Down
2 changes: 1 addition & 1 deletion scripts/auto_update_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def update_example_tests():
print('link: ', ' '.join(cmd))
subprocess.check_call(cmd)
print('run...', output_file)
proc = subprocess.run([output_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
proc = subprocess.run([output_file], capture_output=True)
assert proc.returncode == 0, [proc.returncode, proc.stderror, proc.stdout]
actual = proc.stdout
with open(expected, 'wb') as o:
Expand Down
8 changes: 2 additions & 6 deletions scripts/fuzz_relooper.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,10 @@ def get_phi(j):
print('^')
subprocess.check_call(['./fuzz'], stdout=open('fuzz.wast', 'w'))
print('*')
fast_out = subprocess.run(['bin/wasm-shell', 'fuzz.wast'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout
fast_out = subprocess.run(['bin/wasm-shell', 'fuzz.wast'], capture_output=True).stdout
print('-')
node = os.getenv('NODE', 'nodejs')
slow_out = subprocess.run([node, 'fuzz.slow.js'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).stdout
slow_out = subprocess.run([node, 'fuzz.slow.js'], capture_output=True).stdout
print('_')

if slow_out != fast_out:
Expand Down
9 changes: 2 additions & 7 deletions scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ def has_shell_timeout():

try:
if NODEJS is not None:
subprocess.check_call([NODEJS, '--version'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
subprocess.run([NODEJS, '--version'], check=True, capture_output=True)
except (OSError, subprocess.CalledProcessError):
NODEJS = None
if NODEJS is None:
Expand Down Expand Up @@ -314,12 +312,9 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
self.stderr = stderr


def run_process(cmd, check=True, input=None, capture_output=False, decode_output=True, *args, **kw):
def run_process(cmd, check=True, input=None, decode_output=True, *args, **kw):
if input and type(input) is str:
input = bytes(input, 'utf-8')
if capture_output:
kw['stdout'] = subprocess.PIPE
kw['stderr'] = subprocess.PIPE
ret = subprocess.run(cmd, check=check, input=input, *args, **kw)
if decode_output and ret.stdout is not None:
ret.stdout = ret.stdout.decode('utf-8')
Expand Down
4 changes: 2 additions & 2 deletions scripts/test/wasm_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def check():
wasm = os.path.basename(t).replace('.wast', '')
cmd = shared.WASM_OPT + [t, '--print', '-all']
print(' ', ' '.join(cmd))
proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
proc = subprocess.run(cmd, capture_output=True, text=True)
expected_file = os.path.join(shared.get_test_dir('print'), wasm + '.txt')
shared.fail_if_not_identical_to_file(proc.stdout, expected_file)
cmd = shared.WASM_OPT + [os.path.join(shared.get_test_dir('print'), t), '--print-minified', '-all']
print(' ', ' '.join(cmd))
proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
proc = subprocess.run(cmd, capture_output=True, text=True)
shared.fail_if_not_identical(proc.stdout.strip(), open(os.path.join(shared.get_test_dir('print'), wasm + '.minified.txt')).read().strip())


Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_asyncify.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test(args):
shared.run_process(shared.WASM_OPT + args + [self.input_path('asyncify-stackOverflow.wat'), '--asyncify', '-o', 'c.wasm'])
print(' file size: %d' % os.path.getsize('a.wasm'))
if shared.NODEJS:
shared.run_process([shared.NODEJS, self.input_path('asyncify.js')], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
shared.run_process([shared.NODEJS, self.input_path('asyncify.js')], capture_output=True)

test(['-g'])
test([])
Expand Down Expand Up @@ -55,7 +55,7 @@ def test_asyncify_list_bad(self):
('--pass-arg=asyncify-onlylist@DOS_ReadFile(unsigned short, unsigned char*, unsigned short*, bool)', None),
]:
print(arg, warning)
err = shared.run_process(shared.WASM_OPT + ['-q', self.input_path('asyncify-pure.wat'), '--asyncify', arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE).stderr.strip()
err = shared.run_process(shared.WASM_OPT + ['-q', self.input_path('asyncify-pure.wat'), '--asyncify', arg], capture_output=True).stderr.strip()
if warning:
self.assertIn('warning', err)
self.assertIn(warning, err)
Expand Down
9 changes: 3 additions & 6 deletions test/unit/test_cluster_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ def generate_testcases(self, N, testcase_dir):
f'--output_dir={testcase_dir}',
f'--no_of_files={N}'],
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
capture_output=True)
self.assertEqual(proc.returncode, 0)

# We should have logged the creation of N testcases.
Expand Down Expand Up @@ -444,9 +443,7 @@ def test_file_contents(self):
fuzz_file]
# Capture stderr even though we will not read it. It may
# contain warnings like us passing v8 experimental flags.
proc = subprocess.run(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc = subprocess.run(cmd, capture_output=True)

# An execution is valid if we exited without error, and if we
# managed to run some code before exiting (modules with no
Expand Down Expand Up @@ -487,7 +484,7 @@ def test_zzz_bundle_build_dir(self):

failed = False
try:
subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
subprocess.run(cmd, check=True, capture_output=True)
except subprocess.CalledProcessError:
# Expected error.
failed = True
Expand Down
Loading