Show the diff when a Doxygen test fails.

This is much more readable than just dumping the expected output and the
actual result produced by SWIG, especially for longer Doxygen comments.

Remove the bunch of commented out code and also do not save the results
in the file, this is not very useful as it's not even clear which test the
files correspond to and annoying when these files are left over later. If
anybody really uses this functionality, it ought to be optional.
This commit is contained in:
Vadim Zeitlin 2014-06-15 23:40:34 +02:00
commit 329d64bb04

View file

@ -1,29 +1,8 @@
def check(got, expected): def check(got, expected):
#if got is Null if got is None: # Absence of comment is equivalent to empty comment.
# raise RuntimeError('Expected comment string\n')
#gotStr = string.replace(got, ' ', '')
#gotStr = string.replace(gotStr, '\n', '')
# gotStr = string.replace(gotStr, '\t', '')
#expectedStr = string.replace(expected, ' ', '')
#expectedStr = string.replace(expectedStr, '\n', '')
#expectedStr = string.replace(expectedStr, '\t', '')
if got == None: # when there is no commant attached to a class or function
got = '' got = ''
if not got == expected: if got != expected:
print("\n\n////////////////////////////////////////////////////////////////////////") from difflib import unified_diff
diff = unified_diff(expected.splitlines(True), got.splitlines(True), "expected", "got")
expectedFileName = "expected.txt" raise RuntimeError("Comments don't match:\n" + "".join(diff))
gotFileName = "got.txt"
print("Output is also saved to files '" + expectedFileName + \
"' and '" + gotFileName + "'")
expectedFile = open(expectedFileName, "w")
expectedFile.write(expected)
expectedFile.close()
gotFile = open(gotFileName, "w")
gotFile.write(got)
gotFile.close()
raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n")