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.
2 function! TestCallback(buffer, output)
8 \ 'linter_name': 'testlinter',
12 \ 'text': 'Test Error',
17 call ale#linter#Define('foobar', {
18 \ 'name': 'testlinter',
19 \ 'callback': 'TestCallback',
20 \ 'executable': 'echo',
24 let g:ale_buffer_info = {}
30 delfunction TestCallback
31 call ale#linter#Reset()
32 let g:ale_buffer_info = {}
35 Given foobar (Some imaginary filetype):
40 Execute(ale#util#InSandbox should return 1 when in a sandbox):
41 sandbox let b:in_sandbox = ale#util#InSandbox()
43 Assert b:in_sandbox, 'ale#util#InSandbox() returned 0 for a sandbox command'
45 Execute(ALE shouldn't blow up when run from a sandbox):
46 AssertEqual 'foobar', &filetype
48 sandbox call ale#Queue(0)
49 sandbox call ale#Queue(1)
51 Execute(ALE shouldn't blow up if file cleanup happens in a sandbox):
52 " Make a call to an engine function first, so the function will be defined
53 " before we make the sandbox call.
55 " You are not allowed to define any functions in the sandbox.
56 call ale#engine#InitBufferInfo(3)
58 let g:ale_buffer_info[3] = {
59 \ 'temporary_file_list': ['/tmp/foo'],
60 \ 'temporary_directory_list': ['/tmp/bar'],
62 sandbox call ale#command#RemoveManagedFiles(3)
64 AssertEqual ['/tmp/foo'], g:ale_buffer_info[3].temporary_file_list
65 AssertEqual ['/tmp/bar'], g:ale_buffer_info[3].temporary_directory_list
67 Execute(You shouldn't be able to define linters from the sandbox):
68 call ale#linter#Reset()
69 call ale#linter#PreventLoading('testft')
71 AssertThrows sandbox call ale#linter#Define('testft', {
72 \ 'name': 'testlinter',
73 \ 'output_stream': 'stdout',
74 \ 'executable': 'testlinter',
75 \ 'command': 'testlinter',
76 \ 'callback': 'testCB',
78 AssertEqual 'Vim(let):E48: Not allowed in sandbox', g:vader_exception
79 AssertEqual [], ale#linter#GetAll(['testft'])
81 Execute(You shouldn't be able to register fixers from the sandbox):
82 call ale#fix#registry#Clear()
83 AssertThrows sandbox call ale#fix#registry#Add('prettier', '', ['javascript'], 'prettier')
84 AssertEqual 'Vim(let):E48: Not allowed in sandbox', g:vader_exception
85 AssertEqual [], ale#fix#registry#CompleteFixers('', 'ALEFix ', 7)
87 Execute(You shouldn't be able to get linters from the sandbox, to prevent tampering):
88 AssertThrows sandbox call ale#linter#GetLintersLoaded()
89 AssertEqual 'Vim(let):E48: Not allowed in sandbox', g:vader_exception
91 call ale#linter#Reset()
93 sandbox let b:result = ale#linter#GetAll(['testft'])
95 AssertEqual 0, len(b:result)
97 let b:result = ale#linter#GetAll(['testft'])
99 AssertEqual 1, len(b:result)
101 sandbox let b:result = ale#linter#GetAll(['testft'])
103 AssertEqual 0, len(b:result)