Skip to content

Commit

Permalink
Merge pull request Ericsson#4412 from bruntib/add_path_hash_testcase
Browse files Browse the repository at this point in the history
[test] Add tests for different report hashes
  • Loading branch information
dkrupp authored Jan 7, 2025
2 parents a5fc851 + b89061d commit 8421e16
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
19 changes: 10 additions & 9 deletions web/tests/functional/dynamic_results/test_dynamic_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_sort_by_timestamp(self):
results = self._cc_client.getRunResults(
None, 500, 0, None, ReportFilter(), None, False)

self.assertEqual(len(results), 5)
self.assertEqual(len(results), 6)

sort_timestamp = SortMode(SortType.TIMESTAMP, Order.ASC)

Expand All @@ -119,7 +119,7 @@ def test_sort_by_timestamp(self):
'timestamp' not in results[i + 1].annotations:
continue

self.assertLess(
self.assertLessEqual(
results[i].annotations['timestamp'],
results[i + 1].annotations['timestamp'])

Expand All @@ -134,7 +134,7 @@ def test_filter_by_attribute(self):
results = self._cc_client.getRunResults(
None, 500, 0, None, testcase_filter, None, False)

self.assertEqual(len(results), 2)
self.assertEqual(len(results), 3)

self.assertTrue(all(map(
lambda report: report.annotations['testcase'] == 'TC-1',
Expand All @@ -147,7 +147,7 @@ def test_filter_by_attribute(self):
results = self._cc_client.getRunResults(
None, 500, 0, None, testcase_filter, None, False)

self.assertEqual(len(results), 4)
self.assertEqual(len(results), 5)

self.assertTrue(all(map(
lambda report: report.annotations['testcase'].startswith('TC-'),
Expand All @@ -160,7 +160,7 @@ def test_count_by_attribute(self):
num = self._cc_client.getRunResultCount(
None, ReportFilter(), None)

self.assertEqual(num, 5)
self.assertEqual(num, 6)

testcase_filter = ReportFilter(annotations=[Pair(
first='testcase',
Expand All @@ -169,15 +169,16 @@ def test_count_by_attribute(self):
num = self._cc_client.getRunResultCount(
None, testcase_filter, None)

self.assertEqual(num, 2)
self.assertEqual(num, 3)

def test_unique_path_hash(self):
"""Test that the unique path hash is calculated when two reports differ
only in their annotations."""
results = self._cc_client.getRunResults(
None, 500, 0, None, ReportFilter(), None, False)

# The main.c_lang-tidy<blabla>.plist test file contains two
# bugprone-sizeof-expression reports that differ in their annotations.
# The main.c_lang-tidy<blabla>.plist test file contains three
# bugprone-sizeof-expression reports. Two of them differ in their
# annotations two other differ in their report hash.
# They should be considered as different reports.
self.assertEqual(len(results), 5)
self.assertEqual(len(results), 6)
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,58 @@
</dict>
</array>
</dict>
<!-- This report is the same as the first one, but with a different
issue_hash_content_of_line_in_context. -->
<dict>
<key>category</key>
<string>bugprone</string>
<key>check_name</key>
<string>bugprone-sizeof-expression</string>
<key>description</key>
<string>suspicious usage of 'sizeof(K)'; did you mean 'K'?</string>
<key>issue_hash_content_of_line_in_context</key>
<string>11111111111111111111111111111111</string>
<key>report-annotation</key>
<dict>
<key>timestamp</key>
<string>2000-01-01 09:01</string>
<key>testcase</key>
<string>TS-1</string>
<key>testcase</key>
<string>TC-1</string>
</dict>
<key>location</key>
<dict>
<key>col</key>
<integer>3</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>7</integer>
</dict>
<key>path</key>
<array>
<dict>
<key>depth</key>
<integer>0</integer>
<key>kind</key>
<string>event</string>
<key>location</key>
<dict>
<key>col</key>
<integer>3</integer>
<key>file</key>
<integer>0</integer>
<key>line</key>
<integer>7</integer>
</dict>
<key>message</key>
<string>suspicious usage of 'sizeof(K)'; did you mean 'K'?</string>
</dict>
</array>
</dict>
<!-- This report is the same as the first one, but with a different
report-annotation. -->
<dict>
<key>category</key>
<string>bugprone</string>
Expand Down

0 comments on commit 8421e16

Please sign in to comment.