All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 let g:ale_buffer_info = {}
5 let g:ale_run_synchronously = 1
7 let g:command = 'echo test'
10 let g:preserved_directory = ''
12 function! TestCommandCallback(buffer) abort
13 " We are registering a temporary file, so we should delete it.
14 let g:filename = tempname()
15 call writefile(['foo'], g:filename)
16 call ale#command#ManageFile(a:buffer, g:filename)
18 " We are registering this directory appropriately, so we should delete
20 let g:directory = tempname()
21 call mkdir(g:directory)
22 call writefile(['foo'], g:directory . '/bar')
23 call ale#command#ManageDirectory(a:buffer, g:directory)
25 " We are registering this directory as temporary file, so we
26 " shouldn't delete it.
27 let g:preserved_directory = tempname()
28 call mkdir(g:preserved_directory)
29 call writefile(['foo'], g:preserved_directory . '/bar')
30 call ale#command#ManageFile(a:buffer, g:preserved_directory)
35 function! TestCallback(buffer, output) abort
39 call ale#linter#Define('foobar', {
40 \ 'name': 'testlinter',
41 \ 'executable': has('win32') ? 'cmd' : 'echo',
42 \ 'callback': 'TestCallback',
43 \ 'command': function('TestCommandCallback'),
45 call ale#command#ClearData()
50 if !empty(g:preserved_directory)
51 call delete(g:preserved_directory, 'rf')
54 unlet! g:ale_run_synchronously
58 unlet! g:preserved_directory
59 delfunction TestCommandCallback
60 delfunction TestCallback
61 call ale#linter#Reset()
62 call ale#command#ClearData()
64 Given foobar (Some imaginary filetype):
69 Execute(ALE should delete managed files/directories appropriately after linting):
70 AssertEqual 'foobar', &filetype
73 call ale#test#FlushJobs()
75 Assert !filereadable(g:filename), 'The temporary file was not deleted'
76 Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
77 Assert isdirectory(g:preserved_directory), 'The temporary directory was not kept'
79 Execute(ALE should delete managed files even if no command is run):
80 AssertEqual 'foobar', &filetype
85 call ale#test#WaitForJobs(2000)
87 Assert !filereadable(g:filename), 'The temporary file was not deleted'
88 Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
89 Assert isdirectory(g:preserved_directory), 'The temporary directory was not kept'
91 Execute(ALE should delete managed files when the buffer is removed):
92 call ale#engine#InitBufferInfo(bufnr('%'))
93 call TestCommandCallback(bufnr('%'))
94 call ale#engine#Cleanup(bufnr('%'))
96 Assert !filereadable(g:filename), 'The temporary file was not deleted'
97 Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
98 Assert isdirectory(g:preserved_directory), 'The tempoary directory was not kept'
100 Execute(ALE should create and delete directories for ale#command#CreateDirectory()):
101 call ale#engine#InitBufferInfo(bufnr('%'))
103 let b:dir = ale#command#CreateDirectory(bufnr('%'))
104 let b:dir2 = ale#command#CreateDirectory(bufnr('%'))
106 Assert isdirectory(b:dir), 'The directory was not created'
108 " We should get the correct file permissions.
109 " We want to ensure that the directory is not readable by 'other'
111 AssertEqual 'rwxr-x---', getfperm(b:dir)
114 " The two directories shouldn't be the same.
115 AssertNotEqual b:dir2, b:dir
117 call ale#engine#Cleanup(bufnr('%'))
119 Assert !isdirectory(b:dir), 'The directory was not deleted'
120 Assert !isdirectory(b:dir2), 'The second directory was not deleted'
122 Execute(ale#command#ManageFile should add the file even if the buffer info hasn't been set yet):
123 call ale#command#ManageFile(bufnr(''), '/foo/bar')
129 \ 'file_list': ['/foo/bar'],
130 \ 'directory_list': [],
133 \ ale#command#GetData()
135 Execute(ale#command#ManageDirectory should add the directory even if the buffer info hasn't been set yet):
136 call ale#command#ManageDirectory(bufnr(''), '/foo/bar')
143 \ 'directory_list': ['/foo/bar'],
146 \ ale#command#GetData()