summaryrefslogtreecommitdiff
path: root/test/test_command_chain.vader
blob: 16472041a9aea6892503b3f6b934f08fe502b8c1 (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
64
65
66
Before:
  Save &shell, g:ale_run_synchronously
  let g:ale_run_synchronously = 1
  set shell=/bin/sh
  let g:linter_output = []
  let g:first_echo_called = 0
  let g:second_echo_called = 0
  let g:final_callback_called = 0

  function! CollectResults(buffer, output)
    let g:final_callback_called = 1
    let g:linter_output = a:output
    return []
  endfunction
  function! RunFirstEcho(buffer)
    let g:first_echo_called = 1

    return 'echo foo'
  endfunction
  function! RunSecondEcho(buffer, output)
    let g:second_echo_called = 1

    return 'echo bar'
  endfunction

  call ale#linter#Define('foobar', {
  \ 'name': 'testlinter',
  \ 'callback': 'CollectResults',
  \ 'executable': 'echo',
  \ 'command_chain': [
  \   {
  \     'callback': 'RunFirstEcho',
  \     'output_stream': 'stdout',
  \     'read_buffer': 0,
  \   },
  \   {
  \     'callback': 'RunSecondEcho',
  \     'output_stream': 'stdout',
  \     'read_buffer': 0,
  \   },
  \ ],
  \})

After:
  Restore
  unlet! g:first_echo_called
  unlet! g:second_echo_called
  unlet! g:final_callback_called
  unlet! g:linter_output
  let g:ale_buffer_info = {}
  call ale#linter#Reset()
  delfunction CollectResults
  delfunction RunFirstEcho
  delfunction RunSecondEcho

Given foobar (Some imaginary filetype):
  anything

Execute(Check the results of running the chain):
  AssertEqual 'foobar', &filetype
  call ale#Lint()

  Assert g:first_echo_called, 'The first chain item was not called'
  Assert g:second_echo_called, 'The second chain item was not called'
  Assert g:final_callback_called, 'The final callback was not called'
  AssertEqual ['bar'], g:linter_output