From f64f0bb48c6e080932ec3a99ac03a69a57f7a933 Mon Sep 17 00:00:00 2001 From: Bartolomeo Stellato Date: Fri, 7 Sep 2018 13:16:22 -0400 Subject: [PATCH] Added tests --- ale_linters/julia/languageserver.vim | 5 ++++- autoload/ale/julia.vim | 17 +++++----------- .../julia-languageserver-project/REQUIRE | 0 .../julia-languageserver-project/test.jl | 0 .../test_julia_languageserver_callbacks.vader | 20 +++++++++++++++++++ 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 test/command_callback/julia-languageserver-project/REQUIRE create mode 100644 test/command_callback/julia-languageserver-project/test.jl create mode 100644 test/command_callback/test_julia_languageserver_callbacks.vader diff --git a/ale_linters/julia/languageserver.vim b/ale_linters/julia/languageserver.vim index d59e9959..c5cd063a 100644 --- a/ale_linters/julia/languageserver.vim +++ b/ale_linters/julia/languageserver.vim @@ -1,9 +1,12 @@ " Author: Bartolomeo Stellato " Description: A language server for Julia +" Set julia executable variable +call ale#Set('julia_executable', 'julia') + function! ale_linters#julia#languageserver#GetCommand(buffer) abort let l:julia_executable = ale#Var(a:buffer, 'julia_executable') - return ale#Escape(l:julia_executable) . ale#Escape("--startup-file=no --history-file=no -e 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'") + return ale#Escape(l:julia_executable . " --startup-file=no --history-file=no -e 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'") endfunction call ale#linter#Define('julia', { diff --git a/autoload/ale/julia.vim b/autoload/ale/julia.vim index 71243763..a650504c 100644 --- a/autoload/ale/julia.vim +++ b/autoload/ale/julia.vim @@ -1,27 +1,20 @@ " Author: Bartolomeo Stellato bartolomeo.stellato@gmail.com " Description: Functions for integrating with Julia tools -" Set julia executable variable -call ale#Set('julia_executable', 'julia') - " Find the nearest dir contining a git project as julia project -let g:__ale_julia_project_filenames = ['.git/HEAD'] +let g:__ale_julia_project_filenames = ['REQUIRE'] + function! ale#julia#FindProjectRoot(buffer) abort for l:project_filename in g:__ale_julia_project_filenames let l:full_path = ale#path#FindNearestFile(a:buffer, l:project_filename) if !empty(l:full_path) - let l:path = fnamemodify(l:full_path, ':h') - - " Correct .git path detection. - if fnamemodify(l:path, ':t') is# '.git' - let l:path = fnamemodify(l:path, ':h') - endif - + let l:path = fnamemodify(l:full_path, ':p:h') return l:path endif + endfor return '' -endfunction +endfunction diff --git a/test/command_callback/julia-languageserver-project/REQUIRE b/test/command_callback/julia-languageserver-project/REQUIRE new file mode 100644 index 00000000..e69de29b diff --git a/test/command_callback/julia-languageserver-project/test.jl b/test/command_callback/julia-languageserver-project/test.jl new file mode 100644 index 00000000..e69de29b diff --git a/test/command_callback/test_julia_languageserver_callbacks.vader b/test/command_callback/test_julia_languageserver_callbacks.vader new file mode 100644 index 00000000..163c9496 --- /dev/null +++ b/test/command_callback/test_julia_languageserver_callbacks.vader @@ -0,0 +1,20 @@ +Before: + call ale#assert#SetUpLinterTest('julia', 'languageserver') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'julia', ale#Escape("julia" . " --startup-file=no --history-file=no -e 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'") + +Execute(The executable should be configurable): + let g:ale_julia_executable = 'julia-new' + + AssertLinter 'julia-new', ale#Escape("julia-new" . " --startup-file=no --history-file=no -e 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'") + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('julia-languageserver-project/test.jl') + + AssertLSPProject ale#path#Simplify(g:dir . '/julia-languageserver-project')