Fix an SML variable init bug, and get the SML cm file tests to pass on Windows

This commit is contained in:
w0rp 2017-09-10 00:20:05 +01:00
parent 1a52a2b880
commit c11d2ae375
3 changed files with 11 additions and 14 deletions

View File

@ -1,12 +1,6 @@
" Author: Jake Zimmerman <jake@zimmerman.io>
" Description: SML checking with SML/NJ Compilation Manager
" Let user manually set the CM file (in case our search for a CM file is
" ambiguous and picks the wrong one)
"
" See :help ale-sml-smlnj for more information.
call ale#Set('sml_smlnj_cm_file', '*.cm')
function! ale_linters#sml#smlnj_cm#GetCommand(buffer) abort
let l:cmfile = ale#handlers#sml#GetCmFile(a:buffer)
return 'sml -m ' . l:cmfile . ' < /dev/null'

View File

@ -1,6 +1,11 @@
" Author: Jake Zimmerman <jake@zimmerman.io>
" Description: Shared functions for SML linters
" The glob to use for finding the .cm file.
"
" See :help ale-sml-smlnj for more information.
call ale#Set('sml_smlnj_cm_file', '*.cm')
function! ale#handlers#sml#GetCmFile(buffer) abort
let l:pattern = ale#Var(a:buffer, 'sml_smlnj_cm_file')
let l:as_list = 1

View File

@ -1,31 +1,29 @@
Before:
runtime ale_linters/sml/sml.vim
runtime ale_linters/sml/smlnj.vim
call ale#test#SetDirectory('/testplugin/test')
After:
call ale#test#RestoreDirectory()
call ale#linter#Reset()
# ----- GetCmFile -----
Execute(smlnj finds CM file if it exists):
call ale#test#SetFilename('smlnj/cm/foo.sml')
AssertEqual '/testplugin/test/smlnj/cm/sources.cm', ale#handlers#sml#GetCmFile(bufnr('%'))
AssertEqual
\ ale#path#Winify(g:dir . '/smlnj/cm/sources.cm'),
\ ale#handlers#sml#GetCmFile(bufnr('%'))
Execute(smlnj finds CM file by searching upwards):
call ale#test#SetFilename('smlnj/cm/path/to/bar.sml')
AssertEqual '/testplugin/test/smlnj/cm/sources.cm', ale#handlers#sml#GetCmFile(bufnr('%'))
AssertEqual
\ ale#path#Winify(g:dir . '/smlnj/cm/sources.cm'),
\ ale#handlers#sml#GetCmFile(bufnr('%'))
Execute(smlnj returns '' when no CM file found):
call ale#test#SetFilename('smlnj/file/qux.sml')
AssertEqual '', ale#handlers#sml#GetCmFile(bufnr('%'))
# ----- GetExecutableSmlnjCm & GetExecutableSmlnjFile -----
Execute(CM-project mode enabled when CM file found):
call ale#test#SetFilename('smlnj/cm/foo.sml')