Permalink
Browse files

adapted make script to cabal infrastructure

  • Loading branch information...
1 parent f6e5330 commit 1e86bb17e8ee652f1af79354a8fbc7cbcb1664e9 Alexander Bernauer committed Jul 26, 2011
Showing with 83 additions and 88 deletions.
  1. +0 −4 dmake
  2. +74 −0 make
  3. +0 −42 qmake
  4. +0 −5 rmake
  5. +9 −2 test/Ocram/Test/Main.hs
  6. +0 −35 util/diff_code
View
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-./qmake
-util/diff_code .quickfix
View
@@ -0,0 +1,74 @@
+#!/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", "-d", "2", "-c", color]
+
+ if os.fork() == 0:
+ subprocess.Popen(cmd, 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/Ocram") or line.startswith("test/Ocram")
+
+def isTestError(line):
+ return line.startswith('### Failure 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("runhaskell Setup.hs build")
+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(getFirstLine(err, isTestError), "red")
+ diff_code(err)
+ sys.exit(1)
+
+notify("success", "green")
+sys.exit(0)
View
@@ -1,42 +0,0 @@
-#!/usr/bin/env python
-#vim: set filetype=python
-
-import subprocess
-import sys
-import os
-
-proc = subprocess.Popen("make", stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-out, err = proc.communicate()
-sys.stdout.write(out)
-
-res = []
-notify = None
-for line in err.split("\n"):
- if line.startswith("Ocram/Test"):
- res.append("test/" + line)
- if not notify: notify = line
- elif line.startswith("Ocram/"):
- res.append("src/" + line)
- if not notify: notify = line
- elif line.startswith("Cases:"):
- res.append(line)
- if not notify: notify = line
- else:
- res.append(line)
-
-res_str = "\n".join(res)
-sys.stdout.write(res_str)
-open("./.quickfix", "w").write(res_str)
-
-def notify_results(text):
- if text.endswith("Errors: 0 Failures: 0"):
- color = "green"
- else:
- color = "red"
-
- cmd = ["/usr/bin/osd_cat", "-A", "right", "-d", "2", "-c", color]
-
- if os.fork() == 0:
- subprocess.Popen(cmd, stdin=subprocess.PIPE).communicate(text)
-
-notify_results(notify)
View
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-rsync -aP --delete --exclude .git --exclude bin `pwd` alex@vs0:
-ssh vs0 "cd ocram; ./qmake" > .quickfix
-util/diff_code .quickfix
@@ -1,7 +1,14 @@
module Ocram.Test.Main (main) where
import Ocram.Test.Tests (tests)
-import Test.HUnit (runTestText, putTextToHandle)
+import Test.HUnit (runTestText, putTextToHandle, Counts(errors, failures))
import System.IO (stderr)
+import System.Exit (exitWith, ExitCode(ExitFailure))
-main = runTestText (putTextToHandle stderr False) tests >> return ()
+main = do
+ (count, _ ) <- runTestText (putTextToHandle stderr False) tests
+ if errors count > 0 || failures count > 0
+ then
+ exitWith $ ExitFailure 1
+ else
+ return ()
View
@@ -1,35 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import fileinput
-import subprocess
-import os
-
-expected = []
-got = []
-
-for line in fileinput.input():
- 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()

0 comments on commit 1e86bb1

Please sign in to comment.