fix bug in svn segment

This commit is contained in:
Buck Ryan 2018-07-01 21:13:15 -04:00
parent 067202f71a
commit feb9c8550e
4 changed files with 42 additions and 5 deletions

View file

@ -9,7 +9,8 @@ RUN apk add --no-cache --update \
git \ git \
mercurial \ mercurial \
php5 \ php5 \
subversion && \ subversion \
&& \
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
RUN mkdir /code RUN mkdir /code
@ -22,7 +23,9 @@ RUN bzr whoami "root <root@example.com>" && \
git config --global user.email "root@example.com" && \ git config --global user.email "root@example.com" && \
git config --global user.name "root" git config --global user.name "root"
COPY . ./ # COPY . ./
RUN ./setup.py install # RUN ./setup.py install
ENV USER root ENV USER root
CMD ["nosetests"]

View file

@ -39,7 +39,7 @@ def build_stats():
env=get_subprocess_env()) env=get_subprocess_env())
except OSError: except OSError:
# Popen will throw an OSError if svn is not found # Popen will throw an OSError if svn is not found
return None return None, None
pdata = p.communicate() pdata = p.communicate()
if p.returncode != 0 or pdata[1][:22] == b'svn: warning: W155007:': if p.returncode != 0 or pdata[1][:22] == b'svn: warning: W155007:':
return None, None return None, None

View file

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
docker build -t powerline-shell . docker build -t powerline-shell .
docker run --rm -it powerline-shell nosetests "$@" docker run --rm --interactive --tty \
--volume $PWD:/code \
powerline-shell "$@"

View file

@ -0,0 +1,32 @@
import tempfile
import unittest
import shutil
import mock
import sh
import powerline_shell.segments.svn as svn
from ..testing_utils import dict_side_effect_fn
class SvnTest(unittest.TestCase):
def setUp(self):
self.powerline = mock.MagicMock()
self.powerline.segment_conf.side_effect = dict_side_effect_fn({
("vcs", "show_symbol"): False,
})
self.dirname = tempfile.mkdtemp()
sh.cd(self.dirname)
# sh.svn("init", ".")
self.segment = svn.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)
@mock.patch("powerline_shell.utils.get_PATH")
def test_svn_not_installed(self, get_PATH):
get_PATH.return_value = "" # so svn can't be found
self.segment.start()
self.segment.add_to_powerline()
self.assertEqual(self.powerline.append.call_count, 0)