MCPcopy Create free account
hub / github.com/nodejs/node / testCallGraphMerge

Method testCallGraphMerge

deps/v8/tools/gcmole/gcmole_test.py:157–198  ·  view source on GitHub ↗

Test serializing, deserializing and merging call graphs.

(self)

Source from the content-addressed store, hash-verified

155 {'A': set(), 'B': set('A'), 'C': set(['A', 'B']), 'D': set('B')})
156
157 def testCallGraphMerge(self):
158 """Test serializing, deserializing and merging call graphs."""
159 temp_dir = Path(tempfile.mkdtemp('gcmole_test'))
160
161 call_graph1 = self.create_callgraph(
162 OutputLines('B → C D E', 'D →'), OutputLines('A → B C'))
163 self.assertDictEqual(
164 call_graph1.funcs,
165 {'A': set(), 'B': set('A'), 'C': set(['A', 'B']), 'D': set('B'),
166 'E': set('B')})
167
168 call_graph2 = self.create_callgraph(
169 OutputLines('E → A'), OutputLines('C → D F'))
170 self.assertDictEqual(
171 call_graph2.funcs,
172 {'A': set('E'), 'C': set(), 'D': set('C'), 'E': set(), 'F': set('C')})
173
174 file1 = temp_dir / 'file1.bin'
175 file2 = temp_dir / 'file2.bin'
176 call_graph1.to_file(file1)
177 call_graph2.to_file(file2)
178
179 expected = {'A': set(['E']), 'B': set('A'), 'C': set(['A', 'B']),
180 'D': set(['B', 'C']), 'E': set(['B']), 'F': set(['C'])}
181
182 call_graph = gcmole.CallGraph.from_files(file1, file2)
183 self.assertDictEqual(call_graph.funcs, expected)
184
185 call_graph = gcmole.CallGraph.from_files(file2, file1)
186 self.assertDictEqual(call_graph.funcs, expected)
187
188 call_graph3 = self.create_callgraph(
189 OutputLines('F → G'), OutputLines('G →'))
190 self.assertDictEqual(
191 call_graph3.funcs,
192 {'G': set('F'), 'F': set()})
193
194 file3 = temp_dir / 'file3.bin'
195 call_graph3.to_file(file3)
196
197 call_graph = gcmole.CallGraph.from_files(file1, file2, file3)
198 self.assertDictEqual(call_graph.funcs, dict(G=set('F'), **expected))
199
200 def create_collector(self, outputs):
201 Options = collections.namedtuple('OptionsForCollector', ['allowlist'])

Callers

nothing calls this directly

Calls 6

create_callgraphMethod · 0.95
OutputLinesClass · 0.85
mkdtempMethod · 0.80
to_fileMethod · 0.80
from_filesMethod · 0.80
setFunction · 0.50

Tested by

no test coverage detected