Skip to content
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
65 changes: 39 additions & 26 deletions python/TestHarness/resultssummary/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,40 +474,53 @@ 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))

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
96 changes: 74 additions & 22 deletions python/TestHarness/tests/test_resultssummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,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("Added tests", no_change_build_summary)
self.assertIn("Run time changes", 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 @@ -873,7 +933,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 @@ -924,10 +984,8 @@ def testPRNoChanges(
summary.pr(event_id=EVENT_ID, out_file=out_file.name)
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('Compared against', output)
self.assertIn('No change', output)

@patch.object(TestHarnessResultsSummary, "init_reader")
@patch.object(TestHarnessResultsSummary, "get_event_results")
Expand Down Expand Up @@ -1007,10 +1065,7 @@ def testPRLive(self):
# Check the header format of summary results
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('Compared against', output)

@patch.object(TestHarnessResultsSummary, "init_reader")
@patch.object(TestHarnessResultsSummary, "get_event_results")
Expand All @@ -1035,9 +1090,7 @@ def testMainNoChanges(
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 @@ -1082,13 +1135,12 @@ def testMainRunTimeChanges(
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("Test", output)
self.assertIn("Base (s)", output)
self.assertIn("Head (s)", output)
self.assertIn("+/-", output)
self.assertIn('No added tests', output)
self.assertIn('Run time changes', output)
self.assertIn('Test', output)
self.assertIn('Base (s)', output)
self.assertIn('Head (s)', output)
self.assertIn('+/-', output)
self.assertIn(str(MOCKED_TEST_NAME), output)
self.assertIn("15.00", output)
self.assertIn("10.00", output)
Expand Down