Add Python executables to parse go testify output

This commit is contained in:
Ivan Malison 2016-06-28 19:45:41 -07:00
parent afd00343f4
commit 3e48836ab7
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,8 @@
#!/usr/bin/env python
import parse_go_testify_not_equal
import sys
import json
if __name__ == '__main__':
actual, expected = parse_go_testify_not_equal.get_strings(sys.stdin.read())
print json.dumps({"actual": actual, "expected": expected})

View File

@ -0,0 +1,29 @@
#!/usr/bin/env python
import re
import sys
import tempfile
from subprocess import call
expected_re = re.compile("Error:\\s*Not equal:\\s*(.*?)\\s*\\(expected\\)")
actual_re = re.compile("!=\\s*(.*?)\\s*\(actual\)")
def get_strings(incoming):
expected_match = expected_re.search(incoming)
actual_match = actual_re.search(incoming)
return (eval(expected_match.group(1)), eval(actual_match.group(1)))
if __name__ == '__main__':
stdin = sys.stdin.read()
_, expected_filename = tempfile.mkstemp()
_, actual_filename = tempfile.mkstemp()
expected_text, actual_text = get_strings(stdin)
with open(expected_filename, 'w') as expected_file:
expected_file.write(expected_text)
with open(actual_filename, 'w') as actual_file:
actual_file.write(actual_text)
call(["icdiff", expected_filename, actual_filename, "--show-all-spaces"])