Use stderr for exceptions (#1303)

This commit is contained in:
Ryan Dahl 2018-12-10 17:50:41 -05:00 committed by GitHub
parent 1548792fb3
commit 9a960b9f58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 37 additions and 36 deletions

View file

@ -28,6 +28,15 @@ def read_test(file_name):
return test_dict
def str2bool(v):
if v == "true":
return True
elif v == "false":
return False
else:
raise ValueError("Bad boolean value")
def integration_tests(deno_executable):
assert os.path.isfile(deno_executable)
tests = sorted([
@ -40,6 +49,10 @@ def integration_tests(deno_executable):
test = read_test(test_abs)
exit_code = int(test.get("exit_code", 0))
args = test.get("args", "").split(" ")
check_stderr = str2bool(test.get("check_stderr", "false"))
stderr = subprocess.STDOUT if check_stderr else None
output_abs = os.path.join(root_path, test.get("output", ""))
with open(output_abs, 'r') as f:
expected_out = f.read()
@ -48,7 +61,8 @@ def integration_tests(deno_executable):
print " ".join(cmd)
actual_code = 0
try:
actual_out = subprocess.check_output(cmd, universal_newlines=True)
actual_out = subprocess.check_output(
cmd, universal_newlines=True, stderr=stderr)
except subprocess.CalledProcessError as e:
actual_code = e.returncode
actual_out = e.output