-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added vader tests - made test.sh install necessary dependencies, i.e. neovim & vader - added custom autcomplete_test, since vader did not work
- Loading branch information
Showing
8 changed files
with
174 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test/$VADER_OUTPUT_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ install: | |
- sudo pip install vim-vint | ||
|
||
script: | ||
- bash test/test.sh; | ||
- bash test/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
let s:tests = {} | ||
" Utilities | ||
function! s:Run(function) | ||
let o = &filetype | ||
" let output = call(a:function, ['']) | ||
" call function(a:function) | ||
let output = call(a:function, []) | ||
let &filetype = o | ||
" expecting output to either be a 1 or 0 | ||
let s:tests[a:function[2:]] = output | ||
return output | ||
endfunction | ||
|
||
function! s:Cleanup() | ||
let error = 0 | ||
for test in keys(s:tests) | ||
if !s:tests[test] | ||
let error = 1 | ||
endif | ||
echom test . ' : ' . s:tests[test] | ||
endfor | ||
|
||
if error | ||
" make vim exit with a non-zero value | ||
cquit! | ||
else | ||
qall! | ||
endif | ||
endfunction | ||
|
||
" Test Definitions | ||
function! s:valid_option() | ||
let &filetype = 'python' | ||
|
||
let g:neoformat_python_enabled = ['autopep8', 'yapf'] | ||
let out = neoformat#CompleteFormatters('auto','', 0) | ||
|
||
return ['autopep8'] == out | ||
endfunction | ||
|
||
function! s:invalid_option() | ||
let &filetype = 'javascript' | ||
|
||
let g:neoformat_python_enabled = ['autopep8'] | ||
let out = neoformat#CompleteFormatters('autopep8', '', 0) | ||
|
||
return [] == out | ||
endfunction | ||
|
||
function! s:multi_options() | ||
let &filetype = 'python' | ||
let g:neoformat_python_enabled = ['autopep8', 'yapf'] | ||
let out = neoformat#CompleteFormatters('autopep8', '', 0) | ||
|
||
return [] == out | ||
endfunction | ||
|
||
" Run Tests | ||
call s:Run('s:valid_option') | ||
call s:Run('s:invalid_option') | ||
|
||
|
||
" Check the outputs | ||
call s:Cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Before: | ||
function! g:CmdOutput(cmd) | ||
redir => out | ||
silent exe a:cmd | ||
redir END | ||
return out[1:] | ||
endfunction | ||
|
||
Execute (empty filetype): | ||
let &filetype = '' | ||
let out = g:CmdOutput('Neoformat') | ||
AssertEqual 'Neoformat: formatter not defined for filetype', out | ||
|
||
Execute (filetype without defined formatter): | ||
let &filetype = 'not_real_filetype' | ||
let out = g:CmdOutput('Neoformat') | ||
|
||
AssertEqual 'Neoformat: formatter not defined for ' . &filetype . ' filetype', out | ||
|
||
Execute (formatter defined for other filetype, but is called via user cmd): | ||
let &filetype = 'javascript' | ||
let out = g:CmdOutput('Neoformat autopep8') | ||
|
||
AssertEqual 'Neoformat: formatter definition for autopep8 not found', out | ||
|
||
Execute (user disabled all formatters for current (python) filetype): | ||
let g:neoformat_enabled_python= [] | ||
let &filetype = 'python' | ||
let out = g:CmdOutput('Neoformat') | ||
|
||
AssertEqual 'Neoformat: formatter not defined for ' . &filetype . ' filetype', out | ||
|
||
Execute (user disabled all formatters for current (python) filetype): | ||
let g:neoformat_enabled_python= ['not_real_formatter'] | ||
let &filetype = 'python' | ||
let out = g:CmdOutput('Neoformat') | ||
|
||
AssertEqual 'Neoformat: attempted all formatters available for current filetype', out | ||
|
||
Execute (invalid user cmd: formatter not defined): | ||
let out = g:CmdOutput('Neoformat not_a_real_formatter') | ||
|
||
AssertEqual 'Neoformat: formatter definition for not_a_real_formatter not found', out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ $OSTYPE == darwin* ]]; then | ||
OS='mac' | ||
elif [[ $OSTYPE == linux-gnu* ]]; then | ||
OS='linux' | ||
else | ||
OS='unknown' | ||
fi | ||
|
||
# Vint | ||
if ! hash vint 2>/dev/null; then | ||
pip install vint | ||
fi | ||
|
||
vint . | ||
|
||
# Vader | ||
if [ ! -d "$HOME/.vim/plugged/vader.vim" ]; then | ||
git clone https://github.com/junegunn/vader.vim.git ~/.vim/plugged/vader.vim | ||
fi | ||
|
||
# Make sure neovim is installed | ||
if ! hash nvim 2>/dev/null; then | ||
if [[ $OS == 'linux' ]]; then | ||
sudo add-apt-repository -y ppa:neovim-ppa/unstable | ||
sudo apt-get update | ||
sudo apt-get install -y neovim | ||
elif [[ $OS == 'mac' ]]; then | ||
brew install neovim | ||
fi | ||
fi | ||
|
||
# Run Vader Tests | ||
cd "$( dirname "${BASH_SOURCE[0]}" )" && nvim -u vimrc -c 'Vader! *.vader' > /dev/null | ||
|
||
# Run Autocomplete Tests | ||
nvim -u vimrc -c 'source autocomplete_test.vim' > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Before: | ||
function! g:CmdOutput(cmd) | ||
redir => out | ||
silent exe 'call ' . a:cmd | ||
redir END | ||
return out[1:] | ||
endfunction | ||
|
||
Execute (test log util): | ||
let g:neoformat_verbose = 1 | ||
let out = g:CmdOutput('neoformat#utils#log("test")') | ||
|
||
let g:neoformat_verbose = 0 | ||
AssertEqual 'Neoformat: test', out | ||
|
||
Execute (test msg util): | ||
let g:neoformat_verbose = 0 | ||
let out = g:CmdOutput('neoformat#utils#msg("test")') | ||
|
||
AssertEqual 'Neoformat: test', out | ||
|
||
Execute (test warn util): | ||
let g:neoformat_verbose = 0 | ||
let out = g:CmdOutput('neoformat#utils#warn("test")') | ||
|
||
AssertEqual 'Neoformat: test', out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
filetype off | ||
set runtimepath+=$HOME/.vim/plugged/vader.vim | ||
set runtimepath+=../ | ||
filetype plugin indent on | ||
syntax enable | ||
set nocompatible |