Navigation Menu

Skip to content

Commit

Permalink
Started on Python line parser
Browse files Browse the repository at this point in the history
  • Loading branch information
joonty committed May 6, 2012
1 parent 3b15930 commit 612971a
Showing 1 changed file with 49 additions and 9 deletions.
58 changes: 49 additions & 9 deletions plugin/cakephp.py
Expand Up @@ -10,19 +10,59 @@ def parse_test_output( ):
k = 0
firsterr = -1
numfails = 0
parser = TestOutputParser()
for line in fd:
if k == firsterr:
parsing = True
if parsing:
print line
if found == True:
p = re.compile('There (?:were|was) ([0-9]*) failure',line)
m = p.match(line)
numfails = m.group(1)
firsterr = k+2
break
parser.parseLine(line)
if "Time: " in line:
found = True
k = k + 1

class TestError:
type = "E"
def __init__(self,message,file,line):
self.message = message
self.file = file
self.line = line

class TestFailure(TestError):
def __init__(self,message,file,line):
TestError.__init__(self,message,file,line)
self.type = "F"


class TestErrorManager:

def __init__(self):
self.errors = []
self.failures = []

def addError(self,error):
self.errors.add(error)

def addFailure(self,failure):
self.failures.add(failure)

class TestOutputParser:
parsingErrors = False
parsingFailures = False

def __init__(self):
self.errors = TestErrorManager()

def parseLine(self,line):

matchObj = re.match('There (?:were|was) ([0-9]*) (error|failure)',line,re.M)
if matchObj:
numfails = matchObj.group(1)
type = matchObj.group(2)
if type == "error":
self.parsingErrors = True
print "Parsing errors"
else:
self.parsingFailures = True
print "Parsing failures"
else:
print "No match"
print line

0 comments on commit 612971a

Please sign in to comment.