[LNT] r213338 - Add a option to dry run email commands, add tests of those commands
Chris Matthews
cmatthews5 at apple.com
Thu Jul 17 17:14:24 PDT 2014
Author: cmatthews
Date: Thu Jul 17 19:14:24 2014
New Revision: 213338
URL: http://llvm.org/viewvc/llvm-project?rev=213338&view=rev
Log:
Add a option to dry run email commands, add tests of those commands
We have not previously tested LNT email operations. They break sometimes. This patch adds a —-dry-run (-n) flag to disable the actual sending of the emails so the test suite can call the email commands without sending emails.
Add a test which calls the two main email commands, send-run-comparison, and send-daily-report.
Added:
lnt/trunk/tests/lnttool/email_tools.py
Modified:
lnt/trunk/lnt/lnttool/main.py
Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=213338&r1=213337&r2=213338&view=diff
==============================================================================
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Thu Jul 17 19:14:24 2014
@@ -253,6 +253,10 @@ def action_send_daily_report(name, args)
help="send the report for today (instead of most recent)")
parser.add_option("", "--subject-prefix", dest="subject_prefix",
help="add a subject prefix")
+ parser.add_option("-n", "--dry-run", dest="dry_run", default=False,
+ action="store_true", help="Don't actually send email."
+ " Used for testing.")
+
(opts, args) = parser.parse_args(args)
if len(args) != 2:
@@ -311,10 +315,11 @@ def action_send_daily_report(name, args)
msg.attach(email.mime.text.MIMEText(html_report, "html"))
# Send the report.
- s = smtplib.SMTP(opts.host)
- s.sendmail(opts.from_address, [to_address],
- msg.as_string())
- s.quit()
+ if not opts.dry_run:
+ s = smtplib.SMTP(opts.host)
+ s.sendmail(opts.from_address, [to_address],
+ msg.as_string())
+ s.quit()
def action_send_run_comparison(name, args):
"""send a run-vs-run comparison email"""
@@ -342,6 +347,10 @@ def action_send_run_comparison(name, arg
help="send the report for today (instead of most recent)")
parser.add_option("", "--subject-prefix", dest="subject_prefix",
help="add a subject prefix")
+ parser.add_option("-n", "--dry-run", dest="dry_run", default=False,
+ action="store_true", help="Don't actually send email."
+ " Used for testing.")
+
(opts, args) = parser.parse_args(args)
if len(args) != 3:
@@ -403,10 +412,11 @@ def action_send_run_comparison(name, arg
msg.attach(email.mime.text.MIMEText(html_report, 'html'))
# Send the report.
- s = smtplib.SMTP(opts.host)
- s.sendmail(opts.from_address, [opts.to_address],
- msg.as_string())
- s.quit()
+ if not opts.dry_run:
+ s = smtplib.SMTP(opts.host)
+ s.sendmail(opts.from_address, [opts.to_address],
+ msg.as_string())
+ s.quit()
###
Added: lnt/trunk/tests/lnttool/email_tools.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/lnttool/email_tools.py?rev=213338&view=auto
==============================================================================
--- lnt/trunk/tests/lnttool/email_tools.py (added)
+++ lnt/trunk/tests/lnttool/email_tools.py Thu Jul 17 19:14:24 2014
@@ -0,0 +1,8 @@
+# Testing for the LNT email commands module.
+#
+# RUN: lnt send-run-comparison --dry-run --to some at address.com \
+# RUN: --from some.other at address.com \
+# RUN: --host localhost %{shared_inputs}/SmallInstance/ 1 2
+# RUN: lnt send-daily-report --dry-run --from some.other at address.com \
+# RUN: --host localhost --testsuite nts \
+# RUN: %{shared_inputs}/SmallInstance/ some at address.com
More information about the llvm-commits
mailing list