From 8574b11791cd721b691aa3bdc77c3ecd0c95335b Mon Sep 17 00:00:00 2001
From: Anderson Chauphan
Date: Wed, 14 Feb 2024 15:38:58 -0700
Subject: [PATCH 1/2] Changed test history link in report to be hyperlink
Report output with multiple random failures can get a bit
hard to read. Condensed the output by morphing test history URL
into a hyperlink.
User story: TRILFRAME-614
---
.../cdash_analyze_and_report_random_failures_UnitTests.py | 2 +-
tribits/ci_support/CDashAnalyzeReportRandomFailures.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py b/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py
index 1bff74833..0ff84a1f8 100644
--- a/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py
+++ b/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py
@@ -217,7 +217,7 @@ def test_random_failure(self):
"Found random failing tests: 1
",
"
Build name: build1",
"
Test name: testname1",
- "
Test history URL: https://something[.]com/cdash/queryTests[.]php[?]project=Project%20Name&begin=2018-10-26&end=2018-10-28&filtercount=3&showfilters=1&filtercombine=and&field1=testname&compare1=63&value1=testname1&field2=groupname&compare2=63&value2=Group%20Name&field3=buildname&compare3=63&value3=buildname1",
+ "
Test history URL: Link",
"
Sha1 Pair : \('592ea0d5', 'b07e361c'\)",
"
"
],
diff --git a/tribits/ci_support/CDashAnalyzeReportRandomFailures.py b/tribits/ci_support/CDashAnalyzeReportRandomFailures.py
index 4973bec16..3d6e84ccc 100644
--- a/tribits/ci_support/CDashAnalyzeReportRandomFailures.py
+++ b/tribits/ci_support/CDashAnalyzeReportRandomFailures.py
@@ -334,6 +334,6 @@ def singleSummaryReporter(self, cdashReportData):
cdashReportData.htmlEmailBodyTop += \
"\n
Build name: "+ self.buildName +\
"\n
Test name: "+ self.testName +\
- "\n
Test history URL: "+ self.testHistoryUrl +\
+ "\n
Test history URL: Link" +\
"\n
Sha1 Pair : "+ str(self.sha1Pair)
From 124ec81dcd2ad123d26097cc049a7ffef8ef4d68 Mon Sep 17 00:00:00 2001
From: Anderson Chauphan
Date: Thu, 15 Feb 2024 11:49:08 -0700
Subject: [PATCH 2/2] Added optional argument for email subject-line prefix
(#600)
Added argument to specify a prefix string for the built html
page title and the email subject. This can help with the
tool's email searchability.
---
...cdash_analyze_and_report_random_failures_UnitTests.py | 9 ++++++---
tribits/ci_support/CDashAnalyzeReportRandomFailures.py | 9 +++++++--
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py b/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py
index 1bff74833..a7a12e45e 100644
--- a/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py
+++ b/test/ci_support/cdash_analyze_and_report_random_failures_UnitTests.py
@@ -229,7 +229,9 @@ def test_random_failure(self):
# Test to no random failure case starting from two initial failing tests (ift).
# Each ift has a test history containing multiple tests with passing and nonpassing results,
- # but non share the same sha1 pair.
+ # but non share the same sha1 pair. This also tests the --email-subject-prefix argument
+ # and checks if it's present in the html page title, which is also used in the email subject
+ # line.
#
def test_no_random_failure(self):
@@ -247,7 +249,7 @@ def test_no_random_failure(self):
"PASSED \(rft=0, ift=2\): Project Name Group Name on 2018-10-26 to 2018-10-28"
],
htmlFileRegexList=[
- "PASSED \(rft=0, ift=2\): Project Name Group Name on 2018-10-26 to 2018-10-28
",
+ "Subject Prefix PASSED \(rft=0, ift=2\): Project Name Group Name on 2018-10-26 to 2018-10-28
",
"Random test failure scan results for Project Name from 2018-10-26 to 2018-10-28
",
@@ -260,7 +262,8 @@ def test_no_random_failure(self):
""
],
extraCmndLineOptionsList=[
- "--days-of-history=3"
+ "--days-of-history=3",
+ "--email-subject-prefix='Subject Prefix '"
]
)
diff --git a/tribits/ci_support/CDashAnalyzeReportRandomFailures.py b/tribits/ci_support/CDashAnalyzeReportRandomFailures.py
index 4973bec16..bf63a27c3 100644
--- a/tribits/ci_support/CDashAnalyzeReportRandomFailures.py
+++ b/tribits/ci_support/CDashAnalyzeReportRandomFailures.py
@@ -32,6 +32,7 @@ def runDriver(self):
writeEmailToFile = self.args.write_email_to_file
sendEmailFrom = self.args.send_email_from
sendEmailTo = self.args.send_email_to
+ emailSubjectPrefix = self.args.email_subject_prefix
randomFailureSummaries = []
@@ -231,11 +232,12 @@ def runDriver(self):
cdashReportData.htmlEmailBodyTop += "\n"
defaultPageStyle = CDQAR.getDefaultHtmlPageStyleStr()
+ subjectLine = emailSubjectPrefix+summaryLine
if writeEmailToFile:
print("\nWriting HTML to file: "+writeEmailToFile+" ...")
htmlStr = CDQAR.getFullCDashHtmlReportPageStr(cdashReportData,
- pageTitle=summaryLine, pageStyle=defaultPageStyle)
+ pageTitle=subjectLine, pageStyle=defaultPageStyle)
# print(htmlStr)
with open(writeEmailToFile, 'w') as outFile:
outFile.write(htmlStr)
@@ -247,7 +249,7 @@ def runDriver(self):
emailAddress = emailAddress.strip()
print("\nSending email to '"+emailAddress+"' ...")
msg=CDQAR.createHtmlMimeEmail(
- sendEmailFrom, emailAddress, summaryLine, "", htmlStr)
+ sendEmailFrom, emailAddress, subjectLine, "", htmlStr)
CDQAR.sendMineEmail(msg)
def getCmndLineArgs(self):
@@ -290,6 +292,9 @@ def getCmndLineArgs(self):
parser.add_argument("--send-email-from", default="random-failure-script@noreply.org",
help="Addressed sender of the script summary results email."+\
" [default='random-failure-script@noreply.org']")
+ parser.add_argument("--email-subject-prefix", default="",
+ help="Prefix string added to the email subject line."+\
+ " [default='']")
self.args = parser.parse_args()