Skip to content

Commit

Permalink
fix bug in svn segment
Browse files Browse the repository at this point in the history
  • Loading branch information
Buck Ryan committed Jul 2, 2018
1 parent 067202f commit feb9c85
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ RUN apk add --no-cache --update \
git \
mercurial \
php5 \
subversion && \
subversion \
&& \
rm -rf /var/cache/apk/*

RUN mkdir /code
Expand All @@ -22,7 +23,9 @@ RUN bzr whoami "root <[email protected]>" && \
git config --global user.email "[email protected]" && \
git config --global user.name "root"

COPY . ./
RUN ./setup.py install
# COPY . ./
# RUN ./setup.py install

ENV USER root

CMD ["nosetests"]
2 changes: 1 addition & 1 deletion powerline_shell/segments/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def build_stats():
env=get_subprocess_env())
except OSError:
# Popen will throw an OSError if svn is not found
return None
return None, None
pdata = p.communicate()
if p.returncode != 0 or pdata[1][:22] == b'svn: warning: W155007:':
return None, None
Expand Down
4 changes: 3 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
set -eu
docker build -t powerline-shell .
docker run --rm -it powerline-shell nosetests "$@"
docker run --rm --interactive --tty \
--volume $PWD:/code \
powerline-shell "$@"
32 changes: 32 additions & 0 deletions test/segments_test/svn_test.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit feb9c85

Please sign in to comment.