[dak/master 05/23] Move lintian parsing to daklib.lintian and add tests.
Signed-off-by: Chris Lamb <lamby@debian.org>
---
daklib/lintian.py | 7 +++++++
daklib/queue.py | 14 ++------------
tests/test_lintian.py | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 12 deletions(-)
create mode 100644 daklib/lintian.py
create mode 100755 tests/test_lintian.py
diff --git a/daklib/lintian.py b/daklib/lintian.py
new file mode 100644
index 0000000..fbd1bb7
--- /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 6325fde..da7f5a2 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 0000000..99d5e93
--- /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()
--
1.6.3.3
Reply to: