-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff
More file actions
executable file
·35 lines (29 loc) · 781 Bytes
/
diff
File metadata and controls
executable file
·35 lines (29 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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()