diff options
author | Michael Jungo <michaeljungo92@gmail.com> | 2017-11-12 02:06:28 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-11-12 10:56:53 +0000 |
commit | 3aff1df9615ccc95bb91910f82d43947dd835f28 (patch) | |
tree | ed87452da5b927a9d6ff1e09c3721ea3a0c47d9f | |
parent | d20e3bc71cd835f6708e78c5efea2f6d826d7e4d (diff) | |
download | ale-3aff1df9615ccc95bb91910f82d43947dd835f28.zip |
Add tests for ocaml-language-server callbacks
4 files changed, 108 insertions, 0 deletions
diff --git a/test/command_callback/ols_paths/.merlin b/test/command_callback/ols_paths/.merlin new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ols_paths/.merlin diff --git a/test/command_callback/ols_paths/node_modules/.bin/ocaml-language-server b/test/command_callback/ols_paths/node_modules/.bin/ocaml-language-server new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ols_paths/node_modules/.bin/ocaml-language-server diff --git a/test/command_callback/test_ocaml_ols_callbacks.vader b/test/command_callback/test_ocaml_ols_callbacks.vader new file mode 100644 index 00000000..2c44dbc9 --- /dev/null +++ b/test/command_callback/test_ocaml_ols_callbacks.vader @@ -0,0 +1,54 @@ +Before: + Save &filetype + Save g:ale_ocaml_ols_executable + Save g:ale_ocaml_ols_use_global + + let &filetype = 'ocaml' + unlet! g:ale_ocaml_ols_executable + unlet! g:ale_ocaml_ols_use_global + + runtime ale_linters/ocaml/ols.vim + + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The language string should be correct): + AssertEqual 'ocaml', ale#handlers#ols#GetLanguage(bufnr('')) + +Execute(The default executable should be correct): + AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr('')) + AssertEqual + \ ale#Escape('ocaml-language-server') . ' --stdio', + \ ale#handlers#ols#GetCommand(bufnr('')) + +Execute(The project root should be detected correctly): + AssertEqual '', ale#handlers#ols#GetProjectRoot(bufnr('')) + + call ale#test#SetFilename('ols_paths/file.ml') + + AssertEqual + \ ale#path#Winify(g:dir . '/ols_paths'), + \ ale#handlers#ols#GetProjectRoot(bufnr('')) + +Execute(The local executable should be used when available): + call ale#test#SetFilename('ols_paths/file.ml') + + AssertEqual + \ ale#path#Winify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'), + \ ale#handlers#ols#GetExecutable(bufnr('')) + +Execute(The gloabl executable should always be used when use_global is set): + let g:ale_ocaml_ols_use_global = 1 + call ale#test#SetFilename('ols_paths/file.ml') + + AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr('')) + +Execute(The executable should be configurable): + let g:ale_ocaml_ols_executable = 'foobar' + + AssertEqual 'foobar', ale#handlers#ols#GetExecutable(bufnr('')) diff --git a/test/command_callback/test_reason_ols_callbacks.vader b/test/command_callback/test_reason_ols_callbacks.vader new file mode 100644 index 00000000..ffe403f4 --- /dev/null +++ b/test/command_callback/test_reason_ols_callbacks.vader @@ -0,0 +1,54 @@ +Before: + Save &filetype + Save g:ale_reason_ols_executable + Save g:ale_reason_ols_use_global + + let &filetype = 'reason' + unlet! g:ale_reason_ols_executable + unlet! g:ale_reason_ols_use_global + + runtime ale_linters/reason/ols.vim + + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + + call ale#test#RestoreDirectory() + call ale#linter#Reset() + +Execute(The language string should be correct): + AssertEqual 'reason', ale#handlers#ols#GetLanguage(bufnr('')) + +Execute(The default executable should be correct): + AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr('')) + AssertEqual + \ ale#Escape('ocaml-language-server') . ' --stdio', + \ ale#handlers#ols#GetCommand(bufnr('')) + +Execute(The project root should be detected correctly): + AssertEqual '', ale#handlers#ols#GetProjectRoot(bufnr('')) + + call ale#test#SetFilename('ols_paths/file.re') + + AssertEqual + \ ale#path#Winify(g:dir . '/ols_paths'), + \ ale#handlers#ols#GetProjectRoot(bufnr('')) + +Execute(The local executable should be used when available): + call ale#test#SetFilename('ols_paths/file.re') + + AssertEqual + \ ale#path#Winify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'), + \ ale#handlers#ols#GetExecutable(bufnr('')) + +Execute(The gloabl executable should always be used when use_global is set): + let g:ale_reason_ols_use_global = 1 + call ale#test#SetFilename('ols_paths/file.re') + + AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr('')) + +Execute(The executable should be configurable): + let g:ale_reason_ols_executable = 'foobar' + + AssertEqual 'foobar', ale#handlers#ols#GetExecutable(bufnr('')) |