MCPcopy Index your code
hub / github.com/nodejs/node / MessageTestCase

Class MessageTestCase

test/message/testcfg.py:38–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36ENV_PATTERN = re.compile(r"//\s+Env:(.*)")
37
38class MessageTestCase(test.TestCase):
39
40 def __init__(self, path, file, expected, arch, mode, context, config):
41 super(MessageTestCase, self).__init__(context, path, arch, mode)
42 self.file = file
43 self.expected = expected
44 self.config = config
45 self.arch = arch
46 self.mode = mode
47 self.parallel = True
48
49 def IgnoreLine(self, str):
50 """Ignore empty lines and valgrind output."""
51 if not str.strip(): return True
52 else: return str.startswith('==') or str.startswith('**')
53
54 def IsFailureOutput(self, output):
55 f = open(self.expected)
56 # Skip initial '#' comment and spaces
57 #for line in f:
58 # if (not line.startswith('#')) and (not line.strip()):
59 # break
60 # Convert output lines to regexps that we can match
61 env = { 'basename': basename(self.file) }
62 patterns = [ ]
63 for line in f:
64 if not line.strip():
65 continue
66 pattern = re.escape(line.rstrip() % env)
67 pattern = pattern.replace('\\*', '.*')
68 pattern = '^%s$' % pattern
69 patterns.append(pattern)
70 # Compare actual output with the expected
71 raw_lines = (output.stdout + output.stderr).split('\n')
72 outlines = [ s for s in raw_lines if not self.IgnoreLine(s) ]
73 if len(outlines) != len(patterns):
74 print("length differs.")
75 print("expect=%d" % len(patterns))
76 print("actual=%d" % len(outlines))
77 print("patterns:")
78 for i in range(len(patterns)):
79 print("pattern = %s" % patterns[i])
80 print("outlines:")
81 for i in range(len(outlines)):
82 print("outline = %s" % outlines[i])
83 return True
84 for i in range(len(patterns)):
85 if not re.match(patterns[i], outlines[i]):
86 print("match failed")
87 print("line=%d" % i)
88 print("expect=%s" % patterns[i])
89 print("actual=%s" % outlines[i])
90 return True
91 return False
92
93 def _parse_source_env(self, source):
94 env_match = ENV_PATTERN.search(source)
95 env = {}

Callers 1

ListTestsMethod · 0.85

Calls

no outgoing calls

Tested by 1

ListTestsMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…