summaryrefslogtreecommitdiff
path: root/test/command_callback/test_c_import_paths.vader
blob: 3c2bd79b541b77934fc3d0b1b5586551f90969c3 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
Before:
  " Make sure the c.vim file is loaded first.
  call ale#c#FindProjectRoot(bufnr(''))

  Save g:ale_c_parse_compile_commands
  Save g:ale_c_parse_makefile
  Save g:__ale_c_project_filenames

  let g:original_project_filenames = g:__ale_c_project_filenames
  let g:executable_map = {}

  " Remove the .git/HEAD dir for C import paths for these tests.
  " The tests run inside of a git repo.
  let g:__ale_c_project_filenames = filter(
  \ copy(g:__ale_c_project_filenames),
  \ 'v:val isnot# ''.git/HEAD'''
  \)

  let g:ale_c_parse_compile_commands = 0
  let g:ale_c_parse_makefile = 0

  runtime autoload/ale/engine.vim

  function! ale#engine#IsExecutable(buffer, executable) abort
    return has_key(g:executable_map, a:executable)
  endfunction

After:
  Restore

  unlet! g:original_project_filenames
  unlet! g:executable_map

  runtime autoload/ale/engine.vim

  call ale#assert#TearDownLinterTest()

Execute(The C cc linter should include 'include' directories for projects with a Makefile):
  call ale#assert#SetUpLinterTest('c', 'cc')
  call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.c')
  let g:ale_c_cc_options = ''

  AssertLinter 'gcc',
  \ ale#Escape('gcc')
  \   . ' -S -x c -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/makefile_project/include'))
  \   . ' -'

Execute(The C cc linter should include 'include' directories for projects with a configure file):
  call ale#assert#SetUpLinterTest('c', 'cc')
  call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.c')
  let g:ale_c_cc_options = ''

  AssertLinter 'gcc',
  \ ale#Escape('gcc')
  \   . ' -S -x c -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/configure_project/include'))
  \   . ' -'

Execute(The C cc linter should include root directories for projects with .h files in them):
  call ale#assert#SetUpLinterTest('c', 'cc')
  call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.c')
  let g:ale_c_cc_options = ''

  AssertLinter 'gcc',
  \ ale#Escape('gcc')
  \   . ' -S -x c -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/h_file_project'))
  \   . ' -'

Execute(The C cc linter should include root directories for projects with .hpp files in them):
  call ale#assert#SetUpLinterTest('c', 'cc')
  call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.c')
  let g:ale_c_cc_options = ''

  AssertLinter 'gcc',
  \ ale#Escape('gcc')
  \   . ' -S -x c -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/hpp_file_project'))
  \   . ' -'

Execute(The C ClangTidy handler should include 'include' directories for projects with a Makefile):
  call ale#assert#SetUpLinterTest('c', 'clangtidy')
  call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
  let g:ale_c_clangtidy_options = ''

  AssertLinter 'clang-tidy',
  \ ale#Escape('clang-tidy')
  \ . ' %s '
  \ . '-- -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))

Execute(The C++ cc linter should include 'include' directories for projects with a Makefile):
  call ale#assert#SetUpLinterTest('cpp', 'cc')
  call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
  let g:ale_cpp_cc_options = ''

  AssertLinter 'gcc',
  \   ale#Escape('gcc')
  \   . ' -S -x c++ -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/makefile_project/include'))
  \   . ' -'

Execute(The C++ cc linter should include 'include' directories for projects with a configure file):
  call ale#assert#SetUpLinterTest('cpp', 'cc')
  call ale#test#SetFilename('../test_c_projects/configure_project/subdir/file.cpp')
  let g:ale_cpp_cc_options = ''

  AssertLinter 'gcc',
  \   ale#Escape('gcc')
  \   . ' -S -x c++ -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/configure_project/include'))
  \   . ' -'

Execute(The C++ cc linter should include root directories for projects with .h files in them):
  call ale#assert#SetUpLinterTest('cpp', 'cc')
  call ale#test#SetFilename('../test_c_projects/h_file_project/subdir/file.cpp')
  let g:ale_cpp_cc_options = ''

  AssertLinter 'gcc',
  \   ale#Escape('gcc')
  \   . ' -S -x c++ -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/h_file_project'))
  \   . ' -'

Execute(The C++ cc linter should include root directories for projects with .hpp files in them):
  call ale#assert#SetUpLinterTest('cpp', 'cc')
  call ale#test#SetFilename('../test_c_projects/hpp_file_project/subdir/file.cpp')
  let g:ale_cpp_cc_options = ''

  AssertLinter 'gcc',
  \   ale#Escape('gcc')
  \   . ' -S -x c++ -o ' . (has('win32') ? 'nul': '/dev/null')
  \   . ' -iquote %s:h'
  \   . ' -I' . ale#Escape(ale#path#Simplify(g:dir .  '/../test_c_projects/hpp_file_project'))
  \   . ' -'

Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them):
  call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
  call ale#test#SetFilename('../test_c_projects/json_project/subdir/file.cpp')

  AssertLinter 'clang-tidy',
  \ ale#Escape('clang-tidy')
  \   . ' %s '
  \   . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/json_project/build'))

Execute(The C++ ClangTidy handler should include 'include' directories for projects with a Makefile):
  call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
  call ale#test#SetFilename('../test_c_projects/makefile_project/subdir/file.cpp')
  let g:ale_cpp_clangtidy_options = ''

  AssertLinter 'clang-tidy',
  \ ale#Escape('clang-tidy')
  \ . ' %s '
  \ . '-- -I' . ale#Escape(ale#path#Simplify(g:dir . '/../test_c_projects/makefile_project/include'))