Send an email also when regression test is successful

This commit is contained in:
Bernardo Damele 2013-02-11 18:07:15 +00:00
parent f970b4f240
commit d6db83fe88

View File

@ -30,7 +30,7 @@ SMTP_TIMEOUT = 30
FROM = "regressiontest@sqlmap.org" FROM = "regressiontest@sqlmap.org"
#TO = "dev@sqlmap.org" #TO = "dev@sqlmap.org"
TO = ["bernardo.damele@gmail.com", "miroslav.stampar@gmail.com"] TO = ["bernardo.damele@gmail.com", "miroslav.stampar@gmail.com"]
SUBJECT = "Regression test on %s using revision %s" % (START_TIME, REVISION) SUBJECT = "regression test started on %s using revision %s" % (START_TIME, REVISION)
def prepare_email(content): def prepare_email(content):
global FROM global FROM
@ -132,9 +132,11 @@ def main():
content += "#######################################################################\n\n" content += "#######################################################################\n\n"
end_string = "Regression test finished at %s" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime())
if content: if content:
content += "Regression test finished at %s" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime()) content += end_string
SUBJECT += " (%s)" % ", ".join("#%d" % count for count in test_counts) SUBJECT = "Failed %s (%s)" % (SUBJECT, ", ".join("#%d" % count for count in test_counts))
msg = prepare_email(content) msg = prepare_email(content)
@ -144,6 +146,10 @@ def main():
msg.attach(attachment) msg.attach(attachment)
send_email(msg) send_email(msg)
else:
SUBJECT += "Successful %s" % SUBJECT
msg = prepare_email("All test cases were successful\n\n%s" % end_string)
send_email(msg)
if __name__ == "__main__": if __name__ == "__main__":
log_fd = open("/tmp/sqlmapregressiontest.log", "wb") log_fd = open("/tmp/sqlmapregressiontest.log", "wb")