]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/linter/test_c_cc.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:

Merge commit '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / linter / test_c_cc.vader
1 Before:
2   Save g:ale_c_parse_makefile
3   Save g:ale_history_enabled
4
5   let g:ale_c_parse_makefile = 0
6   let g:ale_history_enabled = 0
7
8   let g:get_cflags_return_value = ''
9   let g:executable_map = {}
10
11   runtime autoload/ale/c.vim
12   runtime autoload/ale/engine.vim
13
14   function! ale#engine#IsExecutable(buffer, executable) abort
15     return has_key(g:executable_map, a:executable)
16   endfunction
17
18   function! ale#c#GetCFlags(buffer, output) abort
19     return g:get_cflags_return_value
20   endfunction
21
22   call ale#assert#SetUpLinterTest('c', 'cc')
23
24   let b:command_tail = ' -S -x c'
25   \   . ' -o ' . (has('win32') ? 'nul': '/dev/null')
26   \   . ' -iquote %s:h'
27   \   . ' -std=c11 -Wall -'
28
29 After:
30   unlet! g:get_cflags_return_value
31   unlet! g:executable_map
32   unlet! b:command_tail
33
34   runtime autoload/ale/c.vim
35   runtime autoload/ale/engine.vim
36
37   call ale#assert#TearDownLinterTest()
38
39 Execute(clang should be used instead of gcc, if available):
40   let g:executable_map = {'clang': 1}
41
42   AssertLinter 'clang', [ale#Escape('clang') . b:command_tail]
43
44 Execute(The executable should be configurable):
45   AssertLinter 'gcc', [ale#Escape('gcc') . b:command_tail]
46
47   let b:ale_c_cc_executable = 'foobar'
48
49   AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
50
51 Execute(The -std flag should be replaced by parsed C flags):
52   let b:command_tail = substitute(b:command_tail, 'c11', 'c99 ', '')
53   let g:get_cflags_return_value = '-std=c99'
54
55   AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
56
57 Execute(gcc should not use -x c-header with header files by default):
58   call ale#test#SetFilename('../test-files/c/makefile_project/subdir/test.h')
59
60   AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
61
62 Execute(clang should use -x c-header with header files by default):
63   let g:executable_map = {'clang': 1}
64   let b:command_tail = substitute(b:command_tail, '-x c', '-x c-header', '')
65
66   call ale#test#SetFilename('../test-files/c/makefile_project/subdir/test.h')
67
68   AssertLinter 'clang', ale#Escape('clang') . b:command_tail
69
70 Execute(gcc should use -x c-header with header files if configured to do so):
71   let b:ale_c_cc_use_header_lang_flag = 1
72   let b:command_tail = substitute(b:command_tail, '-x c', '-x c-header', '')
73
74   call ale#test#SetFilename('../test-files/c/makefile_project/subdir/test.h')
75
76   AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
77
78 Execute(clang should not use -x c-header with header files if configured to do so):
79   let g:executable_map = {'clang': 1}
80   let b:ale_c_cc_use_header_lang_flag = 0
81
82   call ale#test#SetFilename('../test-files/c/makefile_project/subdir/test.h')
83
84   AssertLinter 'clang', ale#Escape('clang') . b:command_tail
85
86 Execute(The header file extensions should be configurable):
87   let g:executable_map = {'clang': 1}
88   let b:command_tail = substitute(b:command_tail, '-x c', '-x c-header', '')
89
90   call ale#assert#SetUpLinterTest('c', 'cc')
91   let b:ale_c_cc_header_exts = ['json']
92   call ale#test#SetFilename('../test-files/c/json_project/build/compile_commands.json')
93
94   AssertLinter 'clang', ale#Escape('clang') . b:command_tail