Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Fix storage of control points #3576

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,17 @@ def convert(
if report.analyzer_name:
diagnostic['type'] = report.analyzer_name

control_edges = []
path = []
if report.bug_path_positions:
for i in range(len(report.bug_path_positions) - 1):
start = report.bug_path_positions[i]
end = report.bug_path_positions[i + 1]
if start.range and end.range:
control_edges.append(self._create_control_edge(
edge = self._create_control_edge(
start.range, start.file,
end.range, end.file,
file_index_map))
file_index_map)
path.append(self._create_control_edges([edge]))
elif len(report.bug_path_events) > 1:
# Create bug path positions from bug path events.
for i in range(len(report.bug_path_events) - 1):
Expand All @@ -497,14 +498,11 @@ def convert(
if start_range == end_range:
continue

control_edges.append(self._create_control_edge(
edge = self._create_control_edge(
start_range, start.file,
end_range, end.file,
file_index_map))

path = []
if control_edges:
path.append(self._create_control_edges(control_edges))
file_index_map)
path.append(self._create_control_edges([edge]))

# Add bug path events after control points.
if report.bug_path_events:
Expand Down Expand Up @@ -572,8 +570,8 @@ def _create_event(
'message': event.message}

if event.range:
data['range'] = self._create_range(
event.range, file_index_map[event.file.original_path])
data['ranges'] = [self._create_range(
event.range, file_index_map[event.file.original_path])]

return data

Expand Down Expand Up @@ -609,8 +607,8 @@ def _create_note(
'message': note.message}

if note.range:
data['range'] = self._create_range(
note.range, file_index_map[note.file.original_path])
data['ranges'] = [self._create_range(
note.range, file_index_map[note.file.original_path])]

return data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@
</dict>
<key>message</key>
<string>Division by zero</string>
<key>range</key>
<key>ranges</key>
<array>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
<array>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
<dict>
<key>col</key>
<integer>13</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>17</integer>
</dict>
</array>
</array>
</dict>
</array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -107,6 +114,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -147,6 +161,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -107,6 +114,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -147,6 +161,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down Expand Up @@ -187,6 +208,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
</dict>
</array>
</dict>
</array>
<key>kind</key>
<string>control</string>
</dict>
<dict>
<key>edges</key>
<array>
<dict>
<key>end</key>
<array>
Expand Down
16 changes: 16 additions & 0 deletions web/tests/functional/report_viewer_api/test_get_run_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ def test_unqiue_report_details(self):

self.assertTrue(any(res.details for res in run_results))

def test_report_path_and_events(self):
"""
Test that bug path events and control points are stored properly.
"""
sort_mode = SortMode(SortType.FILENAME, Order.ASC)

report_filter = ReportFilter(
checkerName=['core.DivideZero'],
filepath=['*path_begin.cpp'])

report = self._cc_client.getRunResults(
[self._runid], 1, 0, [sort_mode], report_filter, None, True)[0]

self.assertEqual(len(report.details.executionPath), 7)
self.assertEqual(len(report.details.pathEvents), 5)

def test_get_checker_labels(self):
checker_labels = self._cc_client.getCheckerLabels([])
self.assertEqual(len(checker_labels), 0)
Expand Down