Skip to content

Commit

Permalink
Added optional argument for email subject-line prefix (TriBITSPub#600)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achauphan committed Feb 15, 2024
1 parent 5e5bd79 commit 124ec81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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=[
"<h2>PASSED \(rft=0, ift=2\): Project Name Group Name on 2018-10-26 to 2018-10-28</h2>",
"<h2>Subject Prefix PASSED \(rft=0, ift=2\): Project Name Group Name on 2018-10-26 to 2018-10-28</h2>",

"<h2>Random test failure scan results for Project Name from 2018-10-26 to 2018-10-28</h2>",

Expand All @@ -260,7 +262,8 @@ def test_no_random_failure(self):
"</p>"
],
extraCmndLineOptionsList=[
"--days-of-history=3"
"--days-of-history=3",
"--email-subject-prefix='Subject Prefix '"
]
)

Expand Down
9 changes: 7 additions & 2 deletions tribits/ci_support/CDashAnalyzeReportRandomFailures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -231,11 +232,12 @@ def runDriver(self):
cdashReportData.htmlEmailBodyTop += "\n</p>"

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)
Expand All @@ -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):
Expand Down Expand Up @@ -290,6 +292,9 @@ def getCmndLineArgs(self):
parser.add_argument("--send-email-from", default="[email protected]",
help="Addressed sender of the script summary results email."+\
" [default='[email protected]']")
parser.add_argument("--email-subject-prefix", default="",
help="Prefix string added to the email subject line."+\
" [default='']")

self.args = parser.parse_args()

Expand Down

0 comments on commit 124ec81

Please sign in to comment.