handled temp file and env variable correctly; added tests
This commit is contained in:
parent
d760558007
commit
81739be0a0
2 changed files with 35 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
||||||
" Author: evnu - https://github.com/evnu
|
" Author: evnu - https://github.com/evnu
|
||||||
" Author: colbydehart - https://github.com/colbydehart
|
" Author: colbydehart - https://github.com/colbydehart
|
||||||
|
" Description: Mix compile checking for Elixir files
|
||||||
|
|
||||||
function! ale_linters#elixir#mix#Handle(buffer, lines) abort
|
function! ale_linters#elixir#mix#Handle(buffer, lines) abort
|
||||||
" Matches patterns like the following:
|
" Matches patterns like the following:
|
||||||
|
@ -29,14 +30,23 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort
|
||||||
return l:output
|
return l:output
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale_linters#elixir#mix#Command(buffer) abort
|
function! ale_linters#elixir#mix#GetCommand(buffer) abort
|
||||||
let l:project_dir = fnamemodify(ale#path#FindNearestFile(a:buffer, 'mix.exs'), ':h')
|
let l:project_root = fnamemodify(ale#path#FindNearestFile(a:buffer, 'mix.exs'), ':h')
|
||||||
return 'cd ' . l:project_dir . ' && MIX_BUILD_PATH=/tmp/mix mix compile %s'
|
|
||||||
|
let l:temp_dir = ale#engine#CreateDirectory(a:buffer)
|
||||||
|
|
||||||
|
let l:mix_build_path = has('win32')
|
||||||
|
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' && '
|
||||||
|
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' '
|
||||||
|
|
||||||
|
return ale#path#CdString(l:project_root)
|
||||||
|
\ . l:mix_build_path
|
||||||
|
\ . ' mix compile %s'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call ale#linter#Define('elixir', {
|
call ale#linter#Define('elixir', {
|
||||||
\ 'name': 'mix',
|
\ 'name': 'mix',
|
||||||
\ 'executable': 'mix',
|
\ 'executable': 'mix',
|
||||||
\ 'command_callback': 'ale_linters#elixir#mix#Command',
|
\ 'command_callback': 'ale_linters#elixir#mix#GetCommand',
|
||||||
\ 'callback': 'ale_linters#elixir#mix#Handle',
|
\ 'callback': 'ale_linters#elixir#mix#Handle',
|
||||||
\})
|
\})
|
||||||
|
|
21
test/handler/test_mix_handler.vader
Normal file
21
test/handler/test_mix_handler.vader
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
Before:
|
||||||
|
runtime ale_linters/elixir/mix.vim
|
||||||
|
|
||||||
|
After:
|
||||||
|
call ale#linter#Reset()
|
||||||
|
|
||||||
|
Execute(The mix handler should parse lines correctly):
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'bufnr': 347,
|
||||||
|
\ 'lnum': 87,
|
||||||
|
\ 'col': 0,
|
||||||
|
\ 'text': 'undefined function update_in/4',
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#elixir#mix#Handle(347, [
|
||||||
|
\ '** (CompileError) apps/sim/lib/sim/server.ex:87: undefined function update_in/4'
|
||||||
|
\ ])
|
Reference in a new issue