summaryrefslogtreecommitdiff
path: root/test/test_sandbox_execution.vader
blob: 7f4941fd68f47e410a013767d12dd158ec478db8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Before:
  function! TestCallback(buffer, output)
    return [
    \ {
    \   'lnum': 1,
    \   'bufnr': 1,
    \   'vcol': 0,
    \   'linter_name': 'testlinter',
    \   'nr': -1,
    \   'type': 'E',
    \   'col': 1,
    \   'text': 'Test Error',
    \ },
    \]
  endfunction

  call ale#linter#Define('foobar', {
  \ 'name': 'testlinter',
  \ 'callback': 'TestCallback',
  \ 'executable': 'echo',
  \ 'command': 'echo',
  \})

  let g:ale_buffer_info = {}

After:
  delfunction TestCallback
  call ale#linter#Reset()
  let g:ale_buffer_info = {}
  unlet! b:in_sandbox

Given foobar (Some imaginary filetype):
  foo
  bar
  baz

Execute(ale#util#InSandbox should return 1 when in a sandbox):
  sandbox let b:in_sandbox = ale#util#InSandbox()

  Assert b:in_sandbox, 'ale#util#InSandbox() returned 0 for a sandbox command'

Execute(ALE shouldn't blow up when run from a sandbox):
  AssertEqual 'foobar', &filetype

  sandbox call ale#Queue(0)
  sandbox call ale#Queue(1)
  sandbox call ale#Lint()

Execute(ALE shouldn't blow up if file cleanup happens in a sandbox):
  " Make a call to an engine function first, so the function will be defined
  " before we make the sandbox call.
  "
  " You are not allowed to define any functions in the sandbox.
  call ale#engine#InitBufferInfo(3)

  let g:ale_buffer_info[3] = {
  \ 'temporary_file_list': ['/tmp/foo'],
  \ 'temporary_directory_list': ['/tmp/bar'],
  \}
  sandbox call ale#engine#RemoveManagedFiles(3)

  AssertEqual ['/tmp/foo'], g:ale_buffer_info[3].temporary_file_list
  AssertEqual ['/tmp/bar'], g:ale_buffer_info[3].temporary_directory_list