From 1a0de488a01d8c6ed88144129b5625f288f7fb91 Mon Sep 17 00:00:00 2001 From: "rhelmer%mozilla.com" Date: Tue, 8 May 2007 22:45:00 +0000 Subject: [PATCH] add test case to ensure that it can still process changes if an InvalidResultError occurs. b=370746, p=bhearsum, r=rhelmer git-svn-id: svn://10.0.0.236/trunk@226143 18797224-902f-48f8-a5cc-f745e15eee43 --- .../buildbot/test/test_bonsaipoller.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mozilla/tools/buildbot/buildbot/test/test_bonsaipoller.py b/mozilla/tools/buildbot/buildbot/test/test_bonsaipoller.py index 79cf5298029..672b70f05b2 100644 --- a/mozilla/tools/buildbot/buildbot/test/test_bonsaipoller.py +++ b/mozilla/tools/buildbot/buildbot/test/test_bonsaipoller.py @@ -3,6 +3,7 @@ from twisted.trial import unittest from buildbot.changes.bonsaipoller import FileNode, CiNode, BonsaiResult, \ BonsaiParser, BonsaiPoller, InvalidResultError, EmptyResult +from buildbot.changes.changes import ChangeMaster from StringIO import StringIO from copy import deepcopy @@ -107,9 +108,18 @@ badResultMsgs = { 'badUnparsedResult': "BonsaiParser did not raise an exception when there was no tags" } +class FakeChangeMaster(ChangeMaster): + def __init__(self): + ChangeMaster.__init__(self) + + def addChange(self, change): + pass + + class FakeBonsaiPoller(BonsaiPoller): def __init__(self): BonsaiPoller.__init__(self, "fake url", "fake module", "fake branch") + self.parent = FakeChangeMaster() class TestBonsaiPoller(unittest.TestCase): def testFullyFormedResult(self): @@ -170,3 +180,18 @@ class TestBonsaiPoller(unittest.TestCase): poller._process_changes(StringIO(badUnparsedResult)) # self.lastChange will not be updated if the change was not submitted self.failUnlessEqual(lastChangeBefore, poller.lastChange) + + def testParserWorksAfterInvalidResult(self): + """Make sure the BonsaiPoller still works after catching an + InvalidResultError""" + + poller = FakeBonsaiPoller() + + lastChangeBefore = poller.lastChange + # generate an exception first + poller._process_changes(StringIO(badUnparsedResult)) + # now give it a valid one... + poller._process_changes(StringIO(goodUnparsedResult)) + # if poller.lastChange has not been updated then the good result + # was not parsed + self.failIfEqual(lastChangeBefore, poller.lastChange)