Skip to content

Commit

Permalink
remove regex_log_evalutator
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jan 6, 2014
1 parent 28bebc1 commit 9f72b02
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
24 changes: 0 additions & 24 deletions master/buildbot/process/buildstep.py
Expand Up @@ -13,8 +13,6 @@
#
# Copyright Buildbot Team Members

import re

from twisted.internet import defer
from twisted.internet import error
from twisted.python import components
Expand All @@ -41,7 +39,6 @@
from buildbot.status.results import SKIPPED
from buildbot.status.results import SUCCESS
from buildbot.status.results import WARNINGS
from buildbot.status.results import worst_status


class BuildStepFailed(Exception):
Expand Down Expand Up @@ -808,27 +805,6 @@ def setStatus(self, cmd, results):
return defer.succeed(None)


# Parses the logs for a list of regexs. Meant to be invoked like:
# regexes = ((re.compile(...), FAILURE), (re.compile(...), WARNINGS))
# self.addStep(ShellCommand,
# command=...,
# ...,
# log_eval_func=lambda c,s: regex_log_evaluator(c, s, regexs)
# )
def regex_log_evaluator(cmd, step_status, regexes):
worst = cmd.results()
for err, possible_status in regexes:
# worst_status returns the worse of the two status' passed to it.
# we won't be changing "worst" unless possible_status is worse than it,
# so we don't even need to check the log if that's the case
if worst_status(worst, possible_status) == possible_status:
if isinstance(err, (basestring)):
err = re.compile(".*%s.*" % err, re.DOTALL)
for l in cmd.logs.values():
if err.search(l.getText()):
worst = possible_status
return worst

# (WithProperties used to be available in this module)
from buildbot.process.properties import WithProperties
_hush_pyflakes = [WithProperties]
Expand Down
49 changes: 0 additions & 49 deletions master/buildbot/test/unit/test_process_buildstep.py
Expand Up @@ -14,12 +14,10 @@
# Copyright Buildbot Team Members

import mock
import re

from buildbot.process import buildstep
from buildbot.process import properties
from buildbot.process import remotecommand
from buildbot.process.buildstep import regex_log_evaluator
from buildbot.status.results import EXCEPTION
from buildbot.status.results import FAILURE
from buildbot.status.results import SKIPPED
Expand Down Expand Up @@ -63,53 +61,6 @@ def run(self):
pass


class TestRegexLogEvaluator(unittest.TestCase):

def makeRemoteCommand(self, rc, stdout, stderr=''):
cmd = fakeremotecommand.FakeRemoteCommand('cmd', {})
cmd.fakeLogData(self, 'stdio', stdout=stdout, stderr=stderr)
cmd.rc = rc
return cmd

def test_find_worse_status(self):
cmd = self.makeRemoteCommand(0, 'This is a big step')
step_status = FakeStepStatus()
r = [(re.compile("This is"), WARNINGS)]
new_status = regex_log_evaluator(cmd, step_status, r)
self.assertEqual(new_status, WARNINGS,
"regex_log_evaluator returned %d, expected %d"
% (new_status, WARNINGS))

def test_multiple_regexes(self):
cmd = self.makeRemoteCommand(0, "Normal stdout text\nan error")
step_status = FakeStepStatus()
r = [(re.compile("Normal stdout"), SUCCESS),
(re.compile("error"), FAILURE)]
new_status = regex_log_evaluator(cmd, step_status, r)
self.assertEqual(new_status, FAILURE,
"regex_log_evaluator returned %d, expected %d"
% (new_status, FAILURE))

def test_exception_not_in_stdout(self):
cmd = self.makeRemoteCommand(0,
"Completely normal output", "exception output")
step_status = FakeStepStatus()
r = [(re.compile("exception"), EXCEPTION)]
new_status = regex_log_evaluator(cmd, step_status, r)
self.assertEqual(new_status, EXCEPTION,
"regex_log_evaluator returned %d, expected %d"
% (new_status, EXCEPTION))

def test_pass_a_string(self):
cmd = self.makeRemoteCommand(0, "Output", "Some weird stuff on stderr")
step_status = FakeStepStatus()
r = [("weird stuff", WARNINGS)]
new_status = regex_log_evaluator(cmd, step_status, r)
self.assertEqual(new_status, WARNINGS,
"regex_log_evaluator returned %d, expected %d"
% (new_status, WARNINGS))


class TestBuildStep(steps.BuildStepMixin, config.ConfigErrorsMixin, unittest.TestCase):

class FakeBuildStep(buildstep.BuildStep):
Expand Down

0 comments on commit 9f72b02

Please sign in to comment.