| 57 | else: return str_arg.startswith('==') or str_arg.startswith('**') |
| 58 | |
| 59 | def IsFailureOutput(self, output): |
| 60 | f = open(self.expected) |
| 61 | # Convert output lines to regexps that we can match |
| 62 | env = { 'basename': basename(self.file) } |
| 63 | patterns = [ ] |
| 64 | for line in f: |
| 65 | if not line.strip(): |
| 66 | continue |
| 67 | pattern = re.escape(line.rstrip() % env) |
| 68 | pattern = pattern.replace('\\*', '.*') |
| 69 | pattern = '^%s$' % pattern |
| 70 | patterns.append(pattern) |
| 71 | # Compare actual output with the expected |
| 72 | raw_lines = (output.stdout + output.stderr).split('\n') |
| 73 | outlines = [ s.rstrip() for s in raw_lines if not self.IgnoreLine(s) ] |
| 74 | if len(outlines) != len(patterns): |
| 75 | print(" length differs.") |
| 76 | print("expect=%d" % len(patterns)) |
| 77 | print("actual=%d" % len(outlines)) |
| 78 | print("patterns:") |
| 79 | for i in range(len(patterns)): |
| 80 | print("pattern = %s" % patterns[i]) |
| 81 | print("outlines:") |
| 82 | for i in range(len(outlines)): |
| 83 | print("outline = %s" % outlines[i]) |
| 84 | return True |
| 85 | for i in range(len(patterns)): |
| 86 | if not re.match(patterns[i], outlines[i]): |
| 87 | print(" match failed") |
| 88 | print("line=%d" % i) |
| 89 | print("expect=%s" % patterns[i]) |
| 90 | print("actual=%s" % outlines[i]) |
| 91 | return True |
| 92 | return False |
| 93 | |
| 94 | def _parse_source_env(self, source): |
| 95 | env_match = ENV_PATTERN.search(source) |