]> err.no Git - dak/commitdiff
Move lintian parsing to daklib.lintian and add tests.
authorChris Lamb <lamby@debian.org>
Sat, 31 Oct 2009 09:33:41 +0000 (09:33 +0000)
committerChris Lamb <lamby@debian.org>
Sat, 31 Oct 2009 23:00:12 +0000 (23:00 +0000)
Signed-off-by: Chris Lamb <lamby@debian.org>
daklib/lintian.py [new file with mode: 0644]
daklib/queue.py
tests/test_lintian.py [new file with mode: 0755]

diff --git a/daklib/lintian.py b/daklib/lintian.py
new file mode 100644 (file)
index 0000000..fbd1bb7
--- /dev/null
@@ -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()
index 6325fde60a48b230e08f850798a645118073e355..da7f5a2148acfd52c27a5fd79215833d5a6be541 100755 (executable)
@@ -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 (executable)
index 0000000..99d5e93
--- /dev/null
@@ -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()