summaryrefslogtreecommitdiff
path: root/test/test_format_temporary_file_creation.vader
blob: 385af9088d78391d0d297f185fa5198c9075eae6 (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
Before:
  Save g:ale_buffer_info
  Save g:ale_echo_cursor
  Save g:ale_enabled
  Save g:ale_run_synchronously
  Save g:ale_set_highlights
  Save g:ale_set_loclist
  Save g:ale_set_quickfix
  Save g:ale_set_signs

  " Disable the features we don't need to check.
  let g:ale_buffer_info = {}
  let g:ale_echo_cursor = 0
  let g:ale_enabled = 1
  let g:ale_run_synchronously = 1
  let g:ale_set_highlights = 0
  let g:ale_set_loclist = 0
  let g:ale_set_quickfix = 0
  let g:ale_set_signs = 0

  let g:output = []

  function! TestCallback(buffer, output)
    " Extract just letters from the output.
    let g:output = filter(
    \ map(a:output, 'matchstr(v:val, ''[a-zA-Z]\+'')'),
    \ '!empty(v:val)'
    \)

    return []
  endfunction

  call ale#linter#PreventLoading('foobar')
  call ale#linter#Define('foobar', {
  \ 'name': 'testlinter',
  \ 'callback': 'TestCallback',
  \ 'executable': has('win32') ? 'cmd' : 'cat',
  \ 'command': has('win32') ? 'type %t' : 'cat %t',
  \})

After:
  Restore

  unlet! g:output
  delfunction TestCallback

  call ale#engine#Cleanup(bufnr(''))
  call ale#linter#Reset()

Given foobar (Some imaginary filetype):
  foo
  bar
  baz

Execute(ALE should be able to read the %t file):
  AssertEqual 'foobar', &filetype

  ALELint

  AssertEqual ['foo', 'bar', 'baz'], g:output