-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake
executable file
·73 lines (56 loc) · 1.97 KB
/
make
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
#vim: set filetype=python
import subprocess
import sys
import os
def execute(commandline):
proc = subprocess.Popen(commandline.split(" "), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = proc.communicate()
sys.stdout.write(out)
sys.stdout.write(err)
return (proc.returncode, out, err)
def notify(text, color):
cmd = "/usr/bin/osd_cat -A right -p bottom -o -40 -d 2 -c %s" % color
if os.fork() == 0:
subprocess.Popen(cmd.split(' '), stdin=subprocess.PIPE).communicate(text)
sys.exit(0)
def getFirstLine(text, predicate):
return filter(predicate, text.split("\n"))[0]
def isBuildError(line):
return line.startswith("src/") or line.startswith("test/")
def isTestError(line):
return line.startswith('### Failure in:') or line.startswith('### Error in:')
def diff_code(text):
expected = []
got = []
for line in text.split("\n"):
if line.startswith('expected: "') and line.count('"') == 2:
(pre, code, post) = line.split('"')
expected.append(code)
if line.startswith(' but got: "') and line.count('"') == 2:
(pre, code, post) = line.split('"')
got.append(code)
assert len(expected) == len(got), str(expected) + "\n" + str(got)
def paste(name, code):
f = open(name, "w")
f.write(code.replace(r'\n', '\n'))
f.close()
inf = "/tmp/infile.c"
outf = "/tmp/outfile.c"
for (ins, outs) in zip(got, expected):
print "----- diff"
paste(inf, ins)
paste(outf, outs)
proc = subprocess.Popen(["wdiff", inf, outf])
proc.wait()
(code, out, err) = execute("cabal-dev install")
if code != 0:
open("./.quickfix", "w").write(err)
notify(getFirstLine(err, isBuildError), "red")
sys.exit(1)
(code, out, err) = execute("./dist/build/Test/Test")
if code != 0:
notify("failed", "red")
sys.exit(1)
notify("success", "green")
sys.exit(0)