mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-07 17:32:00 +00:00
Add a more informative diff output for failed tests
This commit is contained in:
parent
4337a5d86a
commit
1fe5901062
@ -2,6 +2,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import difflib
|
||||||
|
|
||||||
remove_unicode_marker = re.compile(r'u(\'[^\']*\')')
|
remove_unicode_marker = re.compile(r'u(\'[^\']*\')')
|
||||||
remove_long_marker = re.compile(r'([0-9])L')
|
remove_long_marker = re.compile(r'([0-9])L')
|
||||||
@ -36,11 +37,7 @@ def sanitize(lines):
|
|||||||
line = ""
|
line = ""
|
||||||
lines[i] = line
|
lines[i] = line
|
||||||
|
|
||||||
lines = '\n'.join(sorted([l for l in lines if l != ""]))
|
return '\n'.join(sorted([l for l in lines if l != ""]))
|
||||||
|
|
||||||
print('==================')
|
|
||||||
print(lines)
|
|
||||||
return lines
|
|
||||||
|
|
||||||
path = os.path.dirname(__file__)
|
path = os.path.dirname(__file__)
|
||||||
if path != '':
|
if path != '':
|
||||||
@ -69,4 +66,8 @@ elif output == reference:
|
|||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
||||||
print('Test "%s" FAILED!' % name)
|
print('Test "%s" FAILED!' % name)
|
||||||
|
print('--- output')
|
||||||
|
print('+++ reference')
|
||||||
|
print(''.join(difflib.ndiff(output.splitlines(keepends=True),
|
||||||
|
reference.splitlines(keepends=True))))
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
Loading…
Reference in New Issue
Block a user