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

Class TTYTestCase

test/pseudo-tty/testcfg.py:42–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40ENV_PATTERN = re.compile(r"//\s+Env:(.*)")
41
42class TTYTestCase(test.TestCase):
43
44 def __init__(self, path, file, expected, input_arg, arch, mode, context, config):
45 super(TTYTestCase, self).__init__(context, path, arch, mode)
46 self.file = file
47 self.expected = expected
48 self.input = input_arg
49 self.config = config
50 self.arch = arch
51 self.mode = mode
52 self.parallel = True
53
54 def IgnoreLine(self, str_arg):
55 """Ignore empty lines and valgrind output."""
56 if not str_arg.strip(): return True
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)
96 env = {}
97 if env_match:
98 for env_pair in env_match.group(1).strip().split():
99 var, value = env_pair.split('=')

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…