Skip to content

Commit

Permalink
Add step DebLintian
Browse files Browse the repository at this point in the history
Check debian packages for common problems.
  • Loading branch information
jiuka committed Jul 27, 2012
1 parent fb313d5 commit ee27d2d
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
22 changes: 22 additions & 0 deletions master/buildbot/steps/package/deb/__init__.py
@@ -0,0 +1,22 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Portions Copyright Buildbot Team Members
# Portions Copyright Marius Rieder <marius.rieder@durchmesser.ch>
"""
Steps specific to the dep package format.
"""

from lintian import DebLintian

__all__ = ['DebLintian']
67 changes: 67 additions & 0 deletions master/buildbot/steps/package/deb/lintian.py
@@ -0,0 +1,67 @@
# This program is free software; you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Portions Copyright Buildbot Team Members
# Portions Copyright Marius Rieder <marius.rieder@durchmesser.ch>
"""
Steps and objects related to lintian
"""

from buildbot.steps.shell import Test
from buildbot import config

class DebLintian(Test):
name = "lintian"
description = ["Lintian running"]
descriptionDone = ["Lintian"]

warningPattern = '.*W: .*'

fileloc = None

def __init__(self, fileloc=None, **kwargs):
"""
Create the DebLintian object.
@type fileloc: str
@param fileloc: Location of the .deb or .changes to test.
@type kwargs: dict
@param kwargs: all other keyword arguments.
"""
Test.__init__(self, **kwargs)
if fileloc:
self.fileloc = fileloc

if not self.fileloc:
config.error("You must specify a fileloc")

self.command = ["lintian", "-v", self.fileloc]

def createSummary(self, log):
"""
Create nice summary logs.
@param log: log to create summary off of.
"""
warnings = []
errors = []
for line in log.readlines():
if ' W: ' in line:
warnings.append(line)
elif ' E: ' in line:
errors.append(line)

if warnings:
self.addCompleteLog('%d Warnings' % len(warnings), "".join(warnings))
if errors:
self.addCompleteLog('%d Errors' % len(errors), "".join(errors))
44 changes: 44 additions & 0 deletions master/buildbot/test/unit/test_steps_package_deb_lintian.py
@@ -0,0 +1,44 @@
# This file is part of Buildbot. Buildbot is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members

from buildbot.status.results import SUCCESS
from buildbot.steps.package.deb import lintian
from buildbot.test.fake.remotecommand import ExpectShell
from buildbot.test.util import steps
from twisted.trial import unittest
from buildbot import config

class TestDebLintian(steps.BuildStepMixin, unittest.TestCase):

def setUp(self):
return self.setUpBuildStep()

def tearDown(self):
return self.tearDownBuildStep()

def test_no_fileloc(self):
self.assertRaises(config.ConfigErrors, lambda :
lintian.DebLintian())

def test_success(self):
self.setupStep(lintian.DebLintian('foo_0.23_i386.changes'))
self.expectCommands(
ExpectShell(workdir='wkdir', usePTY='slave-config',
command=['lintian', '-v', 'foo_0.23_i386.changes'])
+0)
self.expectOutcome(result=SUCCESS, status_text=['Lintian'])
return self.runStep()


0 comments on commit ee27d2d

Please sign in to comment.