From: Chris Lamb Date: Sat, 31 Oct 2009 09:33:41 +0000 (+0000) Subject: Move lintian parsing to daklib.lintian and add tests. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6929479f75234f9a4c88ce6f297d6a7b070753f6;p=dak Move lintian parsing to daklib.lintian and add tests. Signed-off-by: Chris Lamb --- diff --git a/daklib/lintian.py b/daklib/lintian.py new file mode 100644 index 00000000..fbd1bb72 --- /dev/null +++ b/daklib/lintian.py @@ -0,0 +1,7 @@ +from regexes import re_parse_lintian + +def parse_lintian_output(output): + for line in output.split('\n'): + m = re_parse_lintian.match(line) + if m: + yield m.groups() diff --git a/daklib/queue.py b/daklib/queue.py index 6325fde6..da7f5a21 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -54,6 +54,7 @@ from summarystats import SummaryStats from utils import parse_changes, check_dsc_files from textutils import fix_maintainer from binary import Binary +from lintian import parse_lintian_output ############################################################################### @@ -1317,18 +1318,7 @@ class Upload(object): if self.logger: self.logger.log([self.pkg.changes_file, "check_lintian"] + list(txt)) - # We have output of lintian, this package isn't clean. Lets parse it and see if we - # are having a victim for a reject. - # W: tzdata: binary-without-manpage usr/sbin/tzconfig - for line in output.split('\n'): - m = re_parse_lintian.match(line) - if m is None: - continue - - etype = m.group(1) - epackage = m.group(2) - etag = m.group(3) - etext = m.group(4) + for etype, epackage, etag, etext in parse_lintian_output(output): # So lets check if we know the tag at all. if etag not in tags: diff --git a/tests/test_lintian.py b/tests/test_lintian.py new file mode 100755 index 00000000..99d5e93a --- /dev/null +++ b/tests/test_lintian.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +from base_test import DakTestCase + +import unittest + +from daklib.lintian import parse_lintian_output + +class ParseLintianTestCase(DakTestCase): + def assertParse(self, output, expected): + self.assertEqual( + list(parse_lintian_output(output)), + expected, + ) + + def testSimple(self): + self.assertParse( + 'W: pkgname: some-tag path/to/file', + [('W', 'pkgname', 'some-tag', 'path/to/file')], + ) + + self.assertParse('', []) + self.assertParse('\n\n', []) + self.assertParse('dummy error test', []) + + def testBinaryNoDescription(self): + self.assertParse( + 'W: pkgname: some-tag', + [('W', 'pkgname', 'some-tag', '')], + ) + + def testSource(self): + self.assertParse( + 'W: pkgname source: some-tag', + [('W', 'pkgname source', 'some-tag', '')] + ) + + def testSourceNoDescription(self): + self.assertParse( + 'W: pkgname source: some-tag path/to/file', + [('W', 'pkgname source', 'some-tag', 'path/to/file')] + ) + +if __name__ == '__main__': + unittest.main()