2017-02-11 15:16:08 +00:00
|
|
|
Before:
|
2017-05-31 09:01:41 +00:00
|
|
|
let g:ale_run_synchronously = 1
|
|
|
|
|
2017-02-11 15:16:08 +00:00
|
|
|
let g:command = 'echo test'
|
2017-04-12 22:17:55 +00:00
|
|
|
let g:filename = ''
|
|
|
|
let g:directory = ''
|
|
|
|
let g:preserved_directory = ''
|
2017-02-11 15:16:08 +00:00
|
|
|
|
|
|
|
function! TestCommandCallback(buffer) abort
|
|
|
|
" We are registering a temporary file, so we should delete it.
|
2017-04-12 22:17:55 +00:00
|
|
|
let g:filename = tempname()
|
2017-02-11 15:16:08 +00:00
|
|
|
call writefile(['foo'], g:filename)
|
|
|
|
call ale#engine#ManageFile(a:buffer, g:filename)
|
|
|
|
|
|
|
|
" We are registering this directory appropriately, so we should delete
|
|
|
|
" the whole thing.
|
2017-04-12 22:17:55 +00:00
|
|
|
let g:directory = tempname()
|
2017-02-11 15:16:08 +00:00
|
|
|
call mkdir(g:directory)
|
|
|
|
call writefile(['foo'], g:directory . '/bar')
|
|
|
|
call ale#engine#ManageDirectory(a:buffer, g:directory)
|
|
|
|
|
|
|
|
" We are registering this directory as temporary file, so we
|
|
|
|
" shouldn't delete it.
|
2017-04-12 22:17:55 +00:00
|
|
|
let g:preserved_directory = tempname()
|
2017-02-11 15:16:08 +00:00
|
|
|
call mkdir(g:preserved_directory)
|
|
|
|
call writefile(['foo'], g:preserved_directory . '/bar')
|
|
|
|
call ale#engine#ManageFile(a:buffer, g:preserved_directory)
|
|
|
|
|
|
|
|
return g:command
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! TestCallback(buffer, output) abort
|
|
|
|
return []
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
call ale#linter#Define('foobar', {
|
|
|
|
\ 'name': 'testlinter',
|
|
|
|
\ 'executable': 'echo',
|
|
|
|
\ 'callback': 'TestCallback',
|
|
|
|
\ 'command_callback': 'TestCommandCallback',
|
|
|
|
\})
|
|
|
|
|
|
|
|
After:
|
2017-04-12 22:17:55 +00:00
|
|
|
if !empty(g:preserved_directory)
|
|
|
|
call delete(g:preserved_directory, 'rf')
|
|
|
|
endif
|
2017-02-11 15:16:08 +00:00
|
|
|
|
2017-05-31 09:01:41 +00:00
|
|
|
unlet! g:ale_run_synchronously
|
2017-02-11 15:16:08 +00:00
|
|
|
unlet! g:command
|
|
|
|
unlet! g:filename
|
|
|
|
unlet! g:directory
|
|
|
|
unlet! g:preserved_directory
|
|
|
|
delfunction TestCommandCallback
|
|
|
|
delfunction TestCallback
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
Given foobar (Some imaginary filetype):
|
|
|
|
foo
|
|
|
|
bar
|
|
|
|
baz
|
|
|
|
|
|
|
|
Execute(ALE should delete managed files/directories appropriately after linting):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
|
|
|
call ale#Lint()
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
|
2017-04-12 22:17:55 +00:00
|
|
|
Assert !filereadable(g:filename), 'The temporary file was not deleted'
|
|
|
|
Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
|
|
|
|
Assert isdirectory(g:preserved_directory), 'The temporary directory was not kept'
|
2017-02-11 15:16:08 +00:00
|
|
|
|
|
|
|
Execute(ALE should delete managed files even if no command is run):
|
|
|
|
AssertEqual 'foobar', &filetype
|
|
|
|
|
|
|
|
let g:command = ''
|
|
|
|
|
|
|
|
call ale#Lint()
|
|
|
|
call ale#engine#WaitForJobs(2000)
|
|
|
|
|
2017-04-12 22:17:55 +00:00
|
|
|
Assert !filereadable(g:filename), 'The temporary file was not deleted'
|
|
|
|
Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
|
|
|
|
Assert isdirectory(g:preserved_directory), 'The temporary directory was not kept'
|
2017-02-11 15:16:08 +00:00
|
|
|
|
|
|
|
Execute(ALE should delete managed files when the buffer is removed):
|
|
|
|
call ale#engine#InitBufferInfo(bufnr('%'))
|
|
|
|
call TestCommandCallback(bufnr('%'))
|
2017-07-07 22:47:41 +00:00
|
|
|
call ale#engine#Cleanup(bufnr('%'))
|
2017-02-11 15:16:08 +00:00
|
|
|
|
2017-04-12 22:17:55 +00:00
|
|
|
Assert !filereadable(g:filename), 'The temporary file was not deleted'
|
|
|
|
Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
|
2017-02-11 15:16:08 +00:00
|
|
|
Assert isdirectory(g:preserved_directory), 'The tempoary directory was not kept'
|
2017-03-31 19:14:53 +00:00
|
|
|
|
|
|
|
Execute(ALE should create and delete directories for ale#engine#CreateDirectory()):
|
|
|
|
call ale#engine#InitBufferInfo(bufnr('%'))
|
|
|
|
|
|
|
|
let b:dir = ale#engine#CreateDirectory(bufnr('%'))
|
|
|
|
let b:dir2 = ale#engine#CreateDirectory(bufnr('%'))
|
|
|
|
|
|
|
|
Assert isdirectory(b:dir), 'The directory was not created'
|
|
|
|
|
|
|
|
" We should get the correct file permissions.
|
|
|
|
" We want to ensure that the directory is not readable by 'other'
|
|
|
|
AssertEqual 'rwxr-x---', getfperm(b:dir)
|
|
|
|
|
|
|
|
" The two directories shouldn't be the same.
|
|
|
|
AssertNotEqual b:dir2, b:dir
|
|
|
|
|
2017-07-07 22:47:41 +00:00
|
|
|
call ale#engine#Cleanup(bufnr('%'))
|
2017-03-31 19:14:53 +00:00
|
|
|
|
|
|
|
Assert !isdirectory(b:dir), 'The directory was not deleted'
|
|
|
|
Assert !isdirectory(b:dir2), 'The second directory was not deleted'
|