]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_sandbox_execution.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Do not set EDITOR/VISUAL for shell
[etc/vim.git] / .vim / bundle / ale / test / test_sandbox_execution.vader
1 Before:
2   function! TestCallback(buffer, output)
3     return [
4     \ {
5     \   'lnum': 1,
6     \   'bufnr': 1,
7     \   'vcol': 0,
8     \   'linter_name': 'testlinter',
9     \   'nr': -1,
10     \   'type': 'E',
11     \   'col': 1,
12     \   'text': 'Test Error',
13     \ },
14     \]
15   endfunction
16
17   call ale#linter#Define('foobar', {
18   \ 'name': 'testlinter',
19   \ 'callback': 'TestCallback',
20   \ 'executable': 'echo',
21   \ 'command': 'echo',
22   \})
23
24   let g:ale_buffer_info = {}
25
26 After:
27   unlet! b:in_sandbox
28   unlet! b:result
29
30   delfunction TestCallback
31   call ale#linter#Reset()
32   let g:ale_buffer_info = {}
33
34
35 Given foobar (Some imaginary filetype):
36   foo
37   bar
38   baz
39
40 Execute(ale#util#InSandbox should return 1 when in a sandbox):
41   sandbox let b:in_sandbox = ale#util#InSandbox()
42
43   Assert b:in_sandbox, 'ale#util#InSandbox() returned 0 for a sandbox command'
44
45 Execute(ALE shouldn't blow up when run from a sandbox):
46   AssertEqual 'foobar', &filetype
47
48   sandbox call ale#Queue(0)
49   sandbox call ale#Queue(1)
50
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.
54   "
55   " You are not allowed to define any functions in the sandbox.
56   call ale#engine#InitBufferInfo(3)
57
58   let g:ale_buffer_info[3] = {
59   \ 'temporary_file_list': ['/tmp/foo'],
60   \ 'temporary_directory_list': ['/tmp/bar'],
61   \}
62   sandbox call ale#command#RemoveManagedFiles(3)
63
64   AssertEqual ['/tmp/foo'], g:ale_buffer_info[3].temporary_file_list
65   AssertEqual ['/tmp/bar'], g:ale_buffer_info[3].temporary_directory_list
66
67 Execute(You shouldn't be able to define linters from the sandbox):
68   call ale#linter#Reset()
69   call ale#linter#PreventLoading('testft')
70
71   AssertThrows sandbox call ale#linter#Define('testft', {
72   \ 'name': 'testlinter',
73   \ 'output_stream': 'stdout',
74   \ 'executable': 'testlinter',
75   \ 'command': 'testlinter',
76   \ 'callback': 'testCB',
77   \})
78   AssertEqual 'Vim(let):E48: Not allowed in sandbox', g:vader_exception
79   AssertEqual [], ale#linter#GetAll(['testft'])
80
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)
86
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
90
91   call ale#linter#Reset()
92
93   sandbox let b:result = ale#linter#GetAll(['testft'])
94
95   AssertEqual 0, len(b:result)
96
97   let b:result = ale#linter#GetAll(['testft'])
98
99   AssertEqual 1, len(b:result)
100
101   sandbox let b:result = ale#linter#GetAll(['testft'])
102
103   AssertEqual 0, len(b:result)