Mercurial > hg > graal-compiler
comparison mx/outputparser.py @ 4215:a2caa019ba3a
Fix mx : commands' scripts mx_init hook should be called before parsing command line arguments.
Fix mx : call the mx_post_parse_cmd_line hook from commands' scripts
OutputParser : cosmetic changes to logged output, return the retcode along yith the parsed output
Add a new Test class representing a sanity check and/or a benchmark
Port dacapo command to use this class, begning work on benchmarks
author | Gilles Duboscq <gilles.m.duboscq@gmail.com> |
---|---|
date | Wed, 04 Jan 2012 13:52:46 +0100 |
parents | cb22fcb2e2fc |
children | 47f7d91d34cf |
comparison
equal
deleted
inserted
replaced
4213:e4cfa571d8c4 | 4215:a2caa019ba3a |
---|---|
8 self.nonZeroIsFatal = nonZeroIsFatal | 8 self.nonZeroIsFatal = nonZeroIsFatal |
9 | 9 |
10 def addMatcher(self, matcher): | 10 def addMatcher(self, matcher): |
11 self.matchers.append(matcher) | 11 self.matchers.append(matcher) |
12 | 12 |
13 def parse(self, cmd, cwd=None): | 13 def parse(self, vm, cmd, cwd=None): |
14 ret = [{}] | 14 ret = [{}] |
15 | 15 |
16 def parseLine(line): | 16 def parseLine(line): |
17 line = line.strip() | |
18 anyMatch = False | 17 anyMatch = False |
19 for matcher in self.matchers: | 18 for matcher in self.matchers: |
20 parsed = matcher.parse(line) | 19 parsed = matcher.parse(line.strip()) |
21 if parsed: | 20 if parsed: |
22 anyMatch = True | 21 anyMatch = True |
23 if matcher.startNewLine and len(ret[0]) > 0: | 22 if matcher.startNewLine and len(ret[0]) > 0: |
24 ret.append({}) | 23 ret.append({}) |
25 ret[len(ret)-1].update(parsed) | 24 ret[len(ret)-1].update(parsed) |
26 if anyMatch : | 25 if anyMatch : |
27 mx.log(line) | 26 mx.log('>' + line.rstrip()) |
28 else : | 27 else : |
29 mx.log('# ' + line) | 28 mx.log( line.rstrip()) |
30 | 29 |
31 commands.vm(cmd, nonZeroIsFatal=self.nonZeroIsFatal, out=parseLine, err=parseLine, cwd=cwd) | 30 retcode = commands.vm(cmd, nonZeroIsFatal=self.nonZeroIsFatal, out=parseLine, err=parseLine, cwd=cwd) |
32 return ret | 31 return {'parsed' : ret, 'retcode' : retcode} |
33 | 32 |
34 class Matcher: | 33 class Matcher: |
35 | 34 |
36 def __init__(self, regex, valuesToParse, startNewLine=False): | 35 def __init__(self, regex, valuesToParse, startNewLine=False): |
37 assert isinstance(valuesToParse, dict) | 36 assert isinstance(valuesToParse, dict) |