Permalink
Browse files

Update tests

  • Loading branch information...
1 parent f94851b commit c71c70f0b2674cfeab3fbcfa8d866ee37e17a73f @Shougo committed Dec 25, 2016
View
@@ -8,13 +8,11 @@ python:
- 3.5
install:
- - pip install neovim flake8 nose mock pytest mypy-lang
-
-before_script:
- - git clone https://github.com/syngan/vim-vimlint /tmp/vim-vimlint
- - git clone https://github.com/ynkdir/vim-vimlparser /tmp/vim-vimlparser
- - git clone https://github.com/thinca/vim-themis
+ # Install Neovim via Gist
+ # https://gist.github.com/lambdalisue/0f461f6a91743895394e63a9a1c65232
+ - curl -sL https://gist.githubusercontent.com/lambdalisue/0f461f6a91743895394e63a9a1c65232/raw/install_nvim_for_ci.sh | bash
+ - make install
script:
- - sh /tmp/vim-vimlint/bin/vimlint.sh -l /tmp/vim-vimlint -p /tmp/vim-vimlparser -e EVL103=1 -e EVL102.l:_=1 autoload
- - make test
+ - PATH="$HOME/neovim/bin:$PATH" make test
+ - make lint
View
@@ -1,11 +1,32 @@
-test: vim-themis
- vim-themis/bin/themis --reporter spec test
- nosetests -v rplugin/python3
- flake8 rplugin/
+PATH := ./vim-themis/bin:$(PATH)
+export THEMIS_VIM := nvim
+export THEMIS_ARGS := -e -s --headless
+export THEMIS_HOME := ./vim-themis
+
+
+install: vim-themis
+ pip install neovim --upgrade
+ pip install pytest --upgrade
+ pip install flake8 --upgrade
+ pip install mypy-lang --upgrade
+ pip install vim-vint --upgrade
+
+lint:
+ vint --version
+ vint plugin
+ vint autoload
+ flake8 --version
+ flake8 rplugin/python3/deoplete
+ mypy --version
mypy --silent-imports rplugin/python3/deoplete
-# Use existing vim-themis install from ~/.vim, or clone it.
+test:
+ themis --version
+ themis test/autoload/*
+ pytest --version
+ pytest
+
vim-themis:
git clone https://github.com/thinca/vim-themis vim-themis; \
-.PHONY: test
+.PHONY: install lint test
@@ -66,7 +66,7 @@ function! s:completion_begin(event) abort
\ 'b:deoplete_omni_patterns',
\ 'g:deoplete#omni_patterns',
\ 'g:deoplete#_omni_patterns'))
- if pattern != '' && &l:omnifunc != ''
+ if pattern !=# '' && &l:omnifunc !=# ''
\ && context.input =~# '\%('.pattern.'\)$'
call deoplete#mapping#_set_completeopt()
call feedkeys("\<C-x>\<C-o>", 'n')
@@ -92,7 +92,7 @@ function! s:is_skip(event, context) abort
if &paste
\ || mode() !=# 'i'
\ || (a:event !=# 'Manual' && disable_auto_complete)
- \ || (&l:completefunc != '' && &l:buftype =~# 'nofile')
+ \ || (&l:completefunc !=# '' && &l:buftype =~# 'nofile')
\ || (a:event ==# 'InsertEnter'
\ && has_key(g:deoplete#_context, 'position'))
return 1
@@ -103,7 +103,7 @@ function! s:is_skip(event, context) abort
let word = get(v:completed_item, 'word', '')
let delimiters = filter(copy(g:deoplete#delimiters),
\ 'strridx(word, v:val) == (len(word) - len(v:val))')
- if word == '' || empty(delimiters)
+ if word ==# '' || empty(delimiters)
return 1
endif
endif
@@ -127,7 +127,7 @@ function! s:is_skip_text(event) abort
\ 'b:deoplete_skip_chars', 'g:deoplete#skip_chars')
return (!pumvisible() && virtcol('.') != displaywidth)
- \ || (a:event !=# 'Manual' && input != ''
+ \ || (a:event !=# 'Manual' && input !=# ''
\ && index(skip_chars, input[-1:]) >= 0)
endfunction
@@ -145,7 +145,7 @@ function! s:on_insert_leave() abort
endfunction
function! s:complete_done() abort
- if get(v:completed_item, 'word', '') != ''
+ if get(v:completed_item, 'word', '') !=# ''
let word = v:completed_item.word
if !has_key(g:deoplete#_rank, word)
let g:deoplete#_rank[word] = 1
@@ -154,10 +154,10 @@ endfunction
function! deoplete#init#_context(event, sources) abort
let filetype = (exists('*context_filetype#get_filetype') ?
\ context_filetype#get_filetype() :
- \ (&filetype == '' ? 'nothing' : &filetype))
+ \ (&filetype ==# '' ? 'nothing' : &filetype))
let filetypes = exists('*context_filetype#get_filetypes') ?
\ context_filetype#get_filetypes() :
- \ &filetype == '' ? ['nothing'] :
+ \ &filetype ==# '' ? ['nothing'] :
\ deoplete#util#uniq([&filetype]
\ + split(&filetype, '\.'))
let same_filetypes = exists('*context_filetype#get_same_filetypes') ?
@@ -66,7 +66,7 @@ function! deoplete#util#get_input(event) abort
\ '^.*\%' . (mode ==# 'i' ? col('.') : col('.') - 1)
\ . 'c' . (mode ==# 'i' ? '' : '.'))
- if input =~ '^.\{-}\ze\S\+$'
+ if input =~# '^.\{-}\ze\S\+$'
let complete_str = matchstr(input, '\S\+$')
let input = matchstr(input, '^.\{-}\ze\S\+$')
else
@@ -96,14 +96,14 @@ function! s:vimoption2python(option) abort
let has_dash = 0
let patterns = []
for pattern in split(a:option, ',')
- if pattern == ''
+ if pattern ==# ''
" ,
call add(patterns, ',')
- elseif pattern == '\'
+ elseif pattern ==# '\'
call add(patterns, '\\')
- elseif pattern == '-'
+ elseif pattern ==# '-'
let has_dash = 1
- elseif pattern =~ '\d\+'
+ elseif pattern =~# '\d\+'
call add(patterns, substitute(pattern, '\d\+',
\ '\=nr2char(submatch(0))', 'g'))
else
@@ -1,41 +0,0 @@
-from unittest import TestCase
-from nose.tools import eq_
-from deoplete.util import (
- fuzzy_escape, charwidth, strwidth, truncate, truncate_skipping)
-from deoplete.filter.converter_remove_overlap import overlap_length
-
-
-class FilterTestCase(TestCase):
-
- def test_fuzzy_escapse(self):
- eq_(fuzzy_escape('foo', 0), 'f[^f]*o[^o]*o[^o]*')
- eq_(fuzzy_escape('foo', 1), 'f[^f]*o[^o]*o[^o]*')
- eq_(fuzzy_escape('Foo', 1), 'F[^F]*[oO].*[oO].*')
-
- def test_overlap_length(self):
- eq_(overlap_length('foo bar', 'bar baz'), 3)
- eq_(overlap_length('foobar', 'barbaz'), 3)
- eq_(overlap_length('foob', 'baz'), 1)
- eq_(overlap_length('foobar', 'foobar'), 6)
- eq_(overlap_length('тест', 'ст'), len('ст'))
-
- def test_charwidth(self):
- eq_(charwidth('f'), 1)
- eq_(charwidth(''), 2)
-
- def test_strwidth(self):
- eq_(strwidth('foo bar'), 7)
- eq_(strwidth('あいうえ'), 8)
- eq_(strwidth('fooあい'), 7)
-
- def test_truncate(self):
- eq_(truncate('foo bar', 3), 'foo')
- eq_(truncate('fooあい', 5), 'fooあ')
- eq_(truncate('あいうえ', 4), 'あい')
- eq_(truncate('fooあい', 4), 'foo')
-
- def test_skipping(self):
- eq_(truncate_skipping('foo bar', 3, '..', 3), '..bar')
- eq_(truncate_skipping('foo bar', 6, '..', 3), 'f..bar')
- eq_(truncate_skipping('fooあい', 5, '..', 3), 'f..い')
- eq_(truncate_skipping('あいうえ', 6, '..', 2), 'あ..え')
@@ -1,23 +0,0 @@
-from unittest import TestCase
-from nose.tools import eq_
-from deoplete.util import (
- bytepos2charpos, charpos2bytepos, get_custom, globruntime)
-
-
-class UtilTestCase(TestCase):
-
- def test_pos(self):
- eq_(bytepos2charpos('utf-8', 'foo bar', 3), 3)
- eq_(bytepos2charpos('utf-8', 'あああ', 3), 1)
- eq_(charpos2bytepos('utf-8', 'foo bar', 3), 3)
- eq_(charpos2bytepos('utf-8', 'あああ', 3), 9)
-
- def test_custom(self):
- custom = {'_': {'mark': ''}, 'java': {'converters': []}}
- eq_(get_custom(custom, 'java', 'mark', 'foobar'), '')
- eq_(get_custom(custom, 'java', 'converters', 'foobar'), [])
- eq_(get_custom(custom, 'foo', 'mark', 'foobar'), '')
- eq_(get_custom(custom, 'foo', 'converters', 'foobar'), 'foobar')
-
- def test_globruntime(self):
- eq_(globruntime('/usr', 'bin'), ['/usr/bin'])
File renamed without changes.
View
@@ -0,0 +1,5 @@
+import os
+import sys
+
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+sys.path.insert(0, os.path.join(BASE_DIR, 'rplugin/python3'))
@@ -0,0 +1,34 @@
+import deoplete.util as util
+
+def test_fuzzy_escapse(self):
+ assert fuzzy_escape('foo', 0) == 'f[^f]*o[^o]*o[^o]*'
+ assert fuzzy_escape('foo', 1) == 'f[^f]*o[^o]*o[^o]*'
+ assert fuzzy_escape('Foo', 1) == 'F[^F]*[oO].*[oO].*'
+
+def test_overlap_length(self):
+ assert overlap_length('foo bar', 'bar baz') == 3
+ assert overlap_length('foobar', 'barbaz') == 3
+ assert overlap_length('foob', 'baz') == 1
+ assert overlap_length('foobar', 'foobar') == 6
+ assert overlap_length('тест', 'ст') == len('ст')
+
+def test_charwidth(self):
+ assert charwidth('f') == 1
+ assert charwidth('') == 2
+
+def test_strwidth(self):
+ assert strwidth('foo bar') == 7
+ assert strwidth('あいうえ') == 8
+ assert strwidth('fooあい') == 7
+
+def test_truncate(self):
+ assert truncate('foo bar', 3) == 'foo'
+ assert truncate('fooあい', 5) == 'fooあ'
+ assert truncate('あいうえ', 4) == 'あい'
+ assert truncate('fooあい', 4) == 'foo'
+
+def test_skipping(self):
+ assert truncate_skipping('foo bar', 3, '..', 3) == '..bar'
+ assert truncate_skipping('foo bar', 6, '..', 3) == 'f..bar'
+ assert truncate_skipping('fooあい', 5, '..', 3) == 'f..い'
+ assert truncate_skipping('あいうえ', 6, '..', 2) == 'あ..え'
@@ -0,0 +1,19 @@
+import deoplete.util as util
+
+
+def test_pos():
+ assert util.bytepos2charpos('utf-8', 'foo bar', 3) == 3
+ assert util.bytepos2charpos('utf-8', 'あああ', 3) == 1
+ assert util.charpos2bytepos('utf-8', 'foo bar', 3) == 3
+ assert util.charpos2bytepos('utf-8', 'あああ', 3) == 9
+
+def test_custom(self):
+ custom = {'_': {'mark': ''}, 'java': {'converters': []}}
+ assert get_custom(custom, 'java', 'mark', 'foobar') == ''
+ assert get_custom(custom, 'java', 'converters', 'foobar') == []
+ assert get_custom(custom, 'foo', 'mark', 'foobar') == ''
+ assert get_custom(custom, 'foo', 'converters', 'foobar') == 'foobar'
+
+
+def test_globruntime(self):
+ assert globruntime('/usr', 'bin') == ['/usr/bin']

0 comments on commit c71c70f

Please sign in to comment.