Skip to content
Open
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
69 changes: 42 additions & 27 deletions python/TestHarness/resultssummary/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,40 +474,55 @@ def build_summary(self, removed_table: list, added_table: list, same_table: list
- Removed tests
- Added tests with runtime
- Same tests with high relative runtime rate
If no tests are present in a category, None is displayed
If all table is None, 'No change' will display.
If one or more table is available:
- there is no removed_table, Removed tests portion won't display
- there is no same_table, Run time changes portion won't display
- there is no added_table, 'No added tests' will display
"""
assert isinstance(removed_table, (list, NoneType))
assert isinstance(added_table, (list, NoneType))
assert isinstance(same_table, (list, NoneType))

print("table")
print(removed_table)
print(added_table)
Comment on lines +486 to +488
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("table")
print(removed_table)
print(added_table)

summary = []
# All table are none, display no change
if removed_table is None and added_table is None and same_table is None:
summary.append("\nNo change\n")
else:
# Format removed table
summary.append(
self._format_table(
"\n### Removed tests\n",
removed_table,
["Test","Time (s)"],
""
)
)
# Format added table
summary.append(
self._format_table(
"\n### Added tests\n",
added_table,
["Test", "Time (s)"],
""
)
)
# Format same table
summary.append(
self._format_table(
"\n### Run time changes\n",
same_table,
["Test", "Base (s)", "Head (s)", "+/-"],
""
if removed_table:
summary.append(
self._format_table(
"\n### Removed tests\n",
removed_table,
["Test","Time (s)"],
""
)
)
# Format added table
if added_table:
summary.append(
self._format_table(
"\n### Added tests\n",
added_table,
["Test", "Time (s)"],
""
)
)
else:
summary.append("\n### No added tests\n")
# Format same table
if same_table:
summary.append(
self._format_table(
"\n### Run time changes\n",
same_table,
["Test", "Base (s)", "Head (s)", "+/-"],
""
)
)
)
return "\n".join(summary)

def write_output(self, output_result: str, out_file: str) -> None:
Expand Down
78 changes: 65 additions & 13 deletions python/TestHarness/tests/test_resultssummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,69 @@ def testBuildSummaryNoChanges(self, mock_init_reader):
summary = TestHarnessResultsSummary(None)
no_change_build_summary = summary.build_summary(None, None, None)

self.assertIn('Removed tests', no_change_build_summary)
self.assertIn('No change', no_change_build_summary)

@patch.object(TestHarnessResultsSummary, 'init_reader')
def testBuildSummaryNoRemovedTests(self, mock_init_reader):
"""
Tests building a summary when there are no removed tests.
"""
mock_init_reader.return_value = None
added_table =[[str(MOCKED_TEST_NAME), '15.00']]
same_table =[[str(MOCKED_TEST_NAME), '10.00', '17.00', '70.00%']]
summary = TestHarnessResultsSummary(None)
no_change_build_summary = summary.build_summary(None, added_table, same_table)

self.assertNotIn('Removed tests', no_change_build_summary)
self.assertIn('Added tests', no_change_build_summary)
self.assertIn('Time (s)', no_change_build_summary)
self.assertIn('15.00', no_change_build_summary)
self.assertIn('Run time changes', no_change_build_summary)
self.assertIn('Test', no_change_build_summary)
self.assertIn('Base (s)', no_change_build_summary)
self.assertIn('Head (s)', no_change_build_summary)
self.assertIn('+/-', no_change_build_summary)
self.assertIn(str(MOCKED_TEST_NAME), no_change_build_summary)
self.assertIn('10.00', no_change_build_summary)
self.assertIn('17.00', no_change_build_summary)
self.assertIn('70.00%', no_change_build_summary)

@patch.object(TestHarnessResultsSummary, 'init_reader')
def testBuildSummaryNoRemovedAddedTests(self, mock_init_reader):
"""
Tests building a summary when there are no removed and added test
"""
mock_init_reader.return_value = None
same_table =[[str(MOCKED_TEST_NAME), '10.00', '17.00', '70.00%']]
summary = TestHarnessResultsSummary(None)
no_change_build_summary = summary.build_summary(None, None, same_table)

self.assertNotIn('Removed tests', no_change_build_summary)
self.assertIn('No added tests', no_change_build_summary)
self.assertIn('Run time changes', no_change_build_summary)
self.assertIn('Test', no_change_build_summary)
self.assertIn('Base (s)', no_change_build_summary)
self.assertIn('Head (s)', no_change_build_summary)
self.assertIn('+/-', no_change_build_summary)
self.assertIn(str(MOCKED_TEST_NAME), no_change_build_summary)
self.assertIn('10.00', no_change_build_summary)
self.assertIn('17.00', no_change_build_summary)
self.assertIn('70.00%', no_change_build_summary)

@patch.object(TestHarnessResultsSummary, 'init_reader')
def testBuildSummaryNoAddedRunTimeChanges(self, mock_init_reader):
"""
Tests building a summary when there is no added test and no run time changes.
"""
mock_init_reader.return_value = None
removed_table =[[str(MOCKED_TEST_NAME), '12.00']]
summary = TestHarnessResultsSummary(None)
no_change_build_summary = summary.build_summary(removed_table, None, None)

self.assertNotIn('Run time changes', no_change_build_summary)
self.assertIn('Removed tests', no_change_build_summary)
self.assertIn('No added tests', no_change_build_summary)


@patch.object(TestHarnessResultsSummary, 'init_reader')
def testBuildSummaryHasTests(self, mock_init_reader):
Expand Down Expand Up @@ -802,7 +862,7 @@ def testBuildSummaryHasTests(self, mock_init_reader):
@patch.object(TestHarnessResultsSummary, 'init_reader')
def testWriteOutputFileValidPath(self, mock_init_reader):
"""
Tests output file write and read when output file path exit
Tests output file write and read when output file path exit.
"""
mock_init_reader.return_value = None
summary = TestHarnessResultsSummary(None)
Expand Down Expand Up @@ -854,9 +914,7 @@ def testPRNoChanges(self, mock_get_commit_results, mock_get_event_results, mock_
with open(out_file.name, 'r') as f:
output = f.read()
self.assertIn('Compared against', output)
self.assertIn('Removed tests', output)
self.assertIn('Added tests', output)
self.assertIn('Run time changes', output)
self.assertIn('No change', output)

@patch.object(TestHarnessResultsSummary, 'init_reader')
@patch.object(TestHarnessResultsSummary, 'get_event_results')
Expand Down Expand Up @@ -930,9 +988,6 @@ def testPRLive(self):
with open(out_file.name, 'r') as f:
output = f.read()
self.assertIn('Compared against', output)
self.assertIn('Removed tests', output)
self.assertIn('Added tests', output)
self.assertIn('Run time changes', output)

@patch.object(TestHarnessResultsSummary, 'init_reader')
@patch.object(TestHarnessResultsSummary, 'get_event_results')
Expand All @@ -955,9 +1010,7 @@ def testMainNoChanges(self, mock_get_commit_results, mock_get_event_results, moc
self.assertIn('Compared against', output)
self.assertIn(base_result_with_tests.event_sha[:7], output)
self.assertIn(base_result_with_tests.civet_job_url, output)
self.assertIn('Removed tests', output)
self.assertIn('Added tests', output)
self.assertIn('Run time changes', output)
self.assertIn('No change', output)

@patch.object(TestHarnessResultsSummary, 'init_reader')
@patch.object(TestHarnessResultsSummary, 'get_event_results')
Expand Down Expand Up @@ -994,8 +1047,7 @@ def testMainRunTimeChanges(self, mock_get_commit_results, mock_get_event_results
self.assertIn('Compared against', output)
self.assertIn(base_result_with_tests.event_sha[:7], output)
self.assertIn(base_result_with_tests.civet_job_url, output)
self.assertIn('Removed tests', output)
self.assertIn('Added tests', output)
self.assertIn('No added tests', output)
self.assertIn('Run time changes', output)
self.assertIn('Test', output)
self.assertIn('Base (s)', output)
Expand Down