From c785b7b97a1b2e4a7ccfedf2af55c9abb6b4b9b0 Mon Sep 17 00:00:00 2001 From: Kamil Páral Date: Jan 12 2010 13:13:19 +0000 Subject: rpmguard test, rpmlint test: send e-mail results fixes ticket #110 --- diff --git a/tests/rpmguard/rpmguard.py b/tests/rpmguard/rpmguard.py index cc8805c..f0a8503 100644 --- a/tests/rpmguard/rpmguard.py +++ b/tests/rpmguard/rpmguard.py @@ -34,8 +34,8 @@ class rpmguard(test.test): # is too old rpmlint = utils.system_output("koji latest-pkg dist-f13 --quiet \ rpmlint | cut -d ' ' -f 1", retain_output=True) - utils.system('cd %s; koji download-build --arch noarch --latestfrom dist-f13 \ -rpmlint' % self.tmpdir) + utils.system('cd %s; koji download-build --arch noarch \ +--latestfrom dist-f13 rpmlint' % self.tmpdir) utils.system('yum -y localinstall --nogpgcheck %s/%s.noarch.rpm' \ % (self.tmpdir, rpmlint)) @@ -153,7 +153,8 @@ rpmlint' % self.tmpdir) # Copy arch_results to results and eliminate duplicates for (old_nvr, new_nvr) in self.arch_results.keys(): res_arch = {} - for arch, result in self.arch_results[(old_nvr, new_nvr)].iteritems(): + for arch, result in \ + self.arch_results[(old_nvr, new_nvr)].iteritems(): if not res_arch.has_key(result): res_arch[result] = [arch] else: @@ -169,10 +170,22 @@ rpmlint' % self.tmpdir) self.results.append(info + result + outro) # Write a copy of the output into the log - out.writelines([result + '\n' for result in self.results]) + log = '\n'.join(self.results) + '\n' + out.write(log) out.close() - # TODO email results to package owner/builder + # email results to mailing list + result_email = self.config.get('test','result_email') + if result_email: + warning_count = len([line for line in log.splitlines() \ + if line.startswith('W: ')]) + print 'Sending email with results to %s ...' % result_email + utils.send_email(mail_to=result_email, + mail_from=self.config.get('test','mail_from'), + mail_server=self.config.get('test','smtpserver'), + subject='rpmguard: %u warnings for package %s' % \ + (warning_count, nvr), + body = log) # if some command failed, make this test fail if result == 'FAIL': diff --git a/tests/rpmlint/rpmlint.py b/tests/rpmlint/rpmlint.py index fbf50ff..49f3f11 100644 --- a/tests/rpmlint/rpmlint.py +++ b/tests/rpmlint/rpmlint.py @@ -54,9 +54,25 @@ class rpmlint(test.test): # TODO filter known/waived errors/warnings # - Need to store the filters somewhere authoritative, get signoff, etc # TODO email results to package owner/builder + # Write a copy of the output into the resultsdir out = open(os.path.join(self.resultsdir,'rpmlint.log'),'wb') out.write(self.results) out.close() + + # email results to mailing list + result_email = self.config.get('test','result_email') + if result_email: + # parse last line for summary ('N errors, N warnings') + summary = ((self.results.splitlines()[-1]).split(';')[-1])[1:-1] + print 'Sending email with results to %s ...' % result_email + utils.send_email(mail_to=result_email, + mail_from=self.config.get('test','mail_from'), + mail_server=self.config.get('test','smtpserver'), + subject='rpmlint: %s for package %s' % \ + (summary, nvr), + body = self.results) + + # if some command failed, make this test fail if result == 'FAIL': raise error.TestFail