Skip to content

Commit

Permalink
Merge branch 'pull1545' into eight
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Feb 22, 2015
2 parents 79aa094 + 2d42031 commit ebdc9fa
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
14 changes: 5 additions & 9 deletions master/buildbot/process/logobserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,12 @@ def errReceived(self, data):
self.stderr.append(data)

def _get(self, chunks):
if chunks is None:
return [u'']
if len(chunks) > 1:
chunks = [''.join(chunks)]
elif not chunks:
chunks = [u'']
return chunks
if chunks is None or not chunks:
return u''
return u''.join(chunks)

def getStdout(self):
return self._get(self.stdout)[0]
return self._get(self.stdout)

def getStderr(self):
return self._get(self.stderr)[0]
return self._get(self.stderr)
48 changes: 48 additions & 0 deletions master/buildbot/test/unit/test_process_logobserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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.process import logobserver
from twisted.trial import unittest


class BufferedLogObserver(unittest.TestCase):

def setUp(self):
self.log = logobserver.BufferLogObserver(wantStdout=True, wantStderr=True)

def test_get_stdout_unicode(self):
self.log.outReceived('str')
self.log.errReceived(u'str')

self.assertEqual(u'str', self.log.getStdout())
self.assertEqual(u'str', self.log.getStderr())
self.assertTrue(isinstance(self.log.getStdout(), unicode))
self.assertTrue(isinstance(self.log.getStderr(), unicode))

self.log.outReceived(u'str')
self.log.errReceived(u'str')

self.assertEqual(u'strstr', self.log.getStdout())
self.assertEqual(u'strstr', self.log.getStderr())
self.assertTrue(isinstance(self.log.getStdout(), unicode))
self.assertTrue(isinstance(self.log.getStderr(), unicode))

self.log.outReceived(u'\u2602')
self.log.errReceived(u'\u2602')

self.assertEqual(u'strstr\u2602', self.log.getStdout())
self.assertEqual(u'strstr\u2602', self.log.getStderr())
self.assertTrue(isinstance(self.log.getStdout(), unicode))
self.assertTrue(isinstance(self.log.getStderr(), unicode))
2 changes: 1 addition & 1 deletion master/buildbot/test/unit/test_steps_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from twisted.internet import reactor
from twisted.python import failure
from twisted.python import runtime
from twisted.trial import unittest
from twisted.python.filepath import FilePath
from twisted.trial import unittest


class TestMasterShellCommand(steps.BuildStepMixin, unittest.TestCase):
Expand Down

0 comments on commit ebdc9fa

Please sign in to comment.