Merge branch 'feature/update' into 'master'
Update access to variables See merge request DanielSiepmann/neotags!4
This commit is contained in:
commit
9655fb6b99
5 changed files with 40 additions and 14 deletions
|
@ -11,14 +11,15 @@ build:image:
|
|||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
|
||||
- docker build -t registry.gitlab.com/danielsiepmann/neotags .
|
||||
- docker push registry.gitlab.com/danielsiepmann/neotags:latest
|
||||
# only:
|
||||
# - master
|
||||
only:
|
||||
changes:
|
||||
- Dockerfile
|
||||
|
||||
lint:coding-guideline:
|
||||
image: 'registry.gitlab.com/danielsiepmann/neotags:latest'
|
||||
stage: test
|
||||
script:
|
||||
- pep8 .
|
||||
- pycodestyle --show-source --show-pep8 .
|
||||
|
||||
test:
|
||||
image: 'registry.gitlab.com/danielsiepmann/neotags:latest'
|
||||
|
|
|
@ -5,4 +5,4 @@ LABEL Description="This image should provide environment to lint neotags" Vendor
|
|||
|
||||
# Install dependencies
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache-dir pep8 pynvim pyfakefs==3.1
|
||||
RUN pip install --no-cache-dir pycodestyle==2.5.0 pynvim pyfakefs==3.1
|
||||
|
|
|
@ -48,4 +48,4 @@ Install dependencies:
|
|||
|
||||
Run tests:
|
||||
|
||||
``cd rplugin && python -m unittest test.test_neotags``
|
||||
``docker run -it --rm -v $PWD/rplugin:/project -w /project registry.gitlab.com/danielsiepmann/neotags:latest python -m unittest test.test_neotags``
|
||||
|
|
|
@ -24,7 +24,7 @@ class NeotagsPlugin(object):
|
|||
for option, default in self.options.items():
|
||||
try:
|
||||
variable = 'neotags_%s' % option
|
||||
self.options[option] = self.nvim.vars[variable]
|
||||
self.options[option] = self.nvim.eval('g:%s' % variable)
|
||||
except pynvim.api.nvim.NvimError:
|
||||
self.options[option] = default
|
||||
|
||||
|
@ -36,11 +36,11 @@ class NeotagsPlugin(object):
|
|||
self.debug('Triggered for "%s"' % filename)
|
||||
|
||||
pwd = self.nvim.funcs.execute('pwd').strip()
|
||||
relative_filename = filename.replace(pwd, '').lstrip('\/')
|
||||
relative_filename = filename.replace(pwd, '').lstrip(r'\/')
|
||||
|
||||
try:
|
||||
tags_file = self.get_tags_file(filename)
|
||||
except:
|
||||
except BaseException:
|
||||
self.error(
|
||||
'Could not determine tags file to update for "%s"' % (
|
||||
filename
|
||||
|
@ -53,7 +53,7 @@ class NeotagsPlugin(object):
|
|||
self.strip_existing_tags(tags_file, relative_filename)
|
||||
self.generate_tags(tags_file, relative_filename)
|
||||
self.debug('Tags updated for "%s"' % filename)
|
||||
except:
|
||||
except BaseException:
|
||||
self.error(
|
||||
'Failed to update tags for "%s", reason: %s' % (
|
||||
filename, traceback.format_exc()
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import unittest
|
||||
from unittest.mock import Mock
|
||||
from unittest.mock import MagicMock
|
||||
from pyfakefs import fake_filesystem_unittest
|
||||
|
@ -18,22 +19,42 @@ class TestNeotagsPlugin(fake_filesystem_unittest.TestCase):
|
|||
self.plugin = NeotagsPlugin(Mock(pynvim.api.nvim))
|
||||
|
||||
def test_default_options(self):
|
||||
self.assertEqual('ctags', self.plugin.options['ctags_cmd'])
|
||||
self.assertEqual('tags', self.plugin.options['tags_filename'])
|
||||
self.assertEqual('ctags', self.plugin.options['ctags_cmd'])
|
||||
self.assertEqual(False, self.plugin.options['logging'])
|
||||
|
||||
def test_custom_options(self):
|
||||
self.plugin.nvim.configure_mock(vars={})
|
||||
self.plugin.nvim.vars['neotags_tags_filename'] = 'new_tags'
|
||||
self.plugin.nvim.vars['neotags_ctags_cmd'] = 'new_ctags'
|
||||
self.plugin.nvim.vars['neotags_logging'] = True
|
||||
def eval(argument):
|
||||
if argument == 'g:neotags_tags_filename':
|
||||
return 'new_tags'
|
||||
if argument == 'g:neotags_ctags_cmd':
|
||||
return 'new_ctags'
|
||||
if argument == 'g:neotags_logging':
|
||||
return True
|
||||
|
||||
self.plugin.nvim.configure_mock(eval=eval)
|
||||
self.plugin.update_settings()
|
||||
|
||||
self.assertEqual('new_tags', self.plugin.options['tags_filename'])
|
||||
self.assertEqual('new_ctags', self.plugin.options['ctags_cmd'])
|
||||
self.assertEqual(True, self.plugin.options['logging'])
|
||||
|
||||
def test_fallback_option(self):
|
||||
def eval(argument):
|
||||
if argument == 'g:neotags_tags_filename':
|
||||
return 'new_tags'
|
||||
if argument == 'g:neotags_ctags_cmd':
|
||||
raise pynvim.api.nvim.NvimError('')
|
||||
if argument == 'g:neotags_logging':
|
||||
return True
|
||||
|
||||
self.plugin.nvim.configure_mock(eval=eval)
|
||||
self.plugin.update_settings()
|
||||
|
||||
self.assertEqual('new_tags', self.plugin.options['tags_filename'])
|
||||
self.assertEqual('ctags', self.plugin.options['ctags_cmd'])
|
||||
self.assertEqual(True, self.plugin.options['logging'])
|
||||
|
||||
def test_debug_logs_to_nvim_when_logging_is_active(self):
|
||||
self.plugin.options['logging'] = True
|
||||
self.plugin.nvim.out_write = MagicMock()
|
||||
|
@ -128,3 +149,7 @@ class TestNeotagsPlugin(fake_filesystem_unittest.TestCase):
|
|||
self.plugin.strip_existing_tags(tags_file, os.path.basename(filename))
|
||||
with open(tags_file) as f, open(expected_tags_file) as e:
|
||||
self.assertEqual(e.read(), f.read())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue