Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 36 lines (29 sloc) 781 Bytes
#!/usr/bin/env python
#vim: set filetype=python
import subprocess
import sys
import tempfile
def getline(prefix):
line = sys.stdin.readline()
assert line.startswith(prefix), "prefix not found"
return line[len(prefix)+2:-2].replace(r'\n', '\n')
def linetofile(prefix):
f = tempfile.NamedTemporaryFile(mode="w")
f.write(getline(prefix))
f.flush()
return f
def hline():
sys.stdout.write("-" * 20 + "\n")
while True:
try:
expected = linetofile("expected:")
butgot = linetofile(" but got:")
hline()
proc = subprocess.Popen(["wdiff", expected.name, butgot.name])
proc.wait()
sys.stdout.write("\n")
hline()
except AssertionError, e:
hline()
print e
hline()