Skip to content

Commit

Permalink
Show all the unexpected outputs of the test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Jun 1, 2024
1 parent 9806cb5 commit 1f56921
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rere.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,28 @@ def load_snapshots(file_path: str) -> list[dict]:
print(f"NOTE: You may want to do `{program_name} record {test_list_path}` to update {test_list_path}.bi")
exit(1)
process = subprocess.run(['sh', '-c', shell], capture_output = True);
failed = False
if process.returncode != snapshot['returncode']:
print(f"UNEXPECTED: return code")
print(f" EXPECTED: {snapshot['returncode']}")
print(f" ACTUAL: {process.returncode}")
exit(1)
failed = True
if process.stdout != snapshot['stdout']:
# TODO: support binary outputs
a = snapshot['stdout'].decode('utf-8').splitlines(keepends=True)
b = process.stdout.decode('utf-8').splitlines(keepends=True)
print(f"UNEXPECTED: stdout")
for line in unified_diff(a, b, fromfile="expected", tofile="actual"):
print(line, end='')
exit(1)
failed = True
if process.stderr != snapshot['stderr']:
a = snapshot['stderr'].decode('utf-8').splitlines(keepends=True)
b = process.stderr.decode('utf-8').splitlines(keepends=True)
print(f"UNEXPECTED: stderr")
for line in unified_diff(a, b, fromfile="expected", tofile="actual"):
print(line, end='')
failed = True
if failed:
exit(1)
print('OK')
else:
Expand Down

0 comments on commit 1f56921

Please sign in to comment.