fix(tests): fix ale_c_build_dir_names being unset in tests (#5109)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled

- Use ale#Set() to set the ale_c_build_dir_names variable.
- Ensure SetUpLinterTest() is called before any Save commands in tests.
- Add c.vim to runtime before non-linter tests are executed.
- Remove workarounds in c.vim.
This commit is contained in:
Horacio Sanson
2026-03-29 11:03:19 +09:00
committed by GitHub
parent 90d8f8d2d2
commit 7940a46d5a
7 changed files with 15 additions and 25 deletions

View File

@@ -10,7 +10,7 @@ let s:sep = has('win32') ? '\' : '/'
" Set just so tests can override it.
let g:__ale_c_project_filenames = ['.git/HEAD', 'configure', 'Makefile', 'CMakeLists.txt']
let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [
call ale#Set('c_build_dir_names', [
\ 'build',
\ 'build/Debug',
\ 'build/Release',
@@ -18,10 +18,6 @@ let g:ale_c_build_dir_names = get(g:, 'ale_c_build_dir_names', [
\])
function! s:CanParseMakefile(buffer) abort
" Something somewhere seems to delete this setting in tests, so ensure we
" always have a default value.
call ale#Set('c_parse_makefile', 0)
return ale#Var(a:buffer, 'c_parse_makefile')
endfunction
@@ -246,15 +242,6 @@ function! ale#c#FindCompileCommands(buffer) abort
return [fnamemodify(l:json_file, ':h'), l:json_file]
endif
" Something somewhere seems to delete this setting in tests, so ensure
" we always have a default value.
call ale#Set('c_build_dir_names', [
\ 'build',
\ 'build/Debug',
\ 'build/Release',
\ 'bin',
\])
" Search in build directories if we can't find it in the project.
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
for l:dirname in ale#Var(a:buffer, 'c_build_dir_names')

View File

@@ -1,4 +1,6 @@
Before:
call ale#assert#SetUpLinterTest('c', 'cc')
Save g:ale_c_parse_makefile
Save g:ale_history_enabled
@@ -19,8 +21,6 @@ Before:
return g:get_cflags_return_value
endfunction
call ale#assert#SetUpLinterTest('c', 'cc')
let b:command_tail = ' -S -x c'
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
\ . ' -iquote %s:h'

View File

@@ -1,10 +1,10 @@
Before:
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
call ale#assert#SetUpLinterTest('c', 'clangtidy')
call ale#test#SetFilename('test.c')
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
After:
call ale#assert#TearDownLinterTest()

View File

@@ -1,10 +1,10 @@
Before:
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
call ale#test#SetFilename('test.cpp')
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
After:
call ale#assert#TearDownLinterTest()

View File

@@ -1,4 +1,6 @@
Before:
call ale#assert#SetUpLinterTest('cpp', 'cc')
Save g:ale_c_parse_makefile
Save g:ale_history_enabled
@@ -8,7 +10,6 @@ Before:
let g:get_cflags_return_value = ''
let g:executable_map = {}
runtime autoload/ale/c.vim
runtime autoload/ale/engine.vim
function! ale#engine#IsExecutable(buffer, executable) abort
@@ -19,8 +20,6 @@ Before:
return g:get_cflags_return_value
endfunction
call ale#assert#SetUpLinterTest('cpp', 'cc')
let b:command_tail = ' -S -x c++'
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
\ . ' -iquote %s:h'

View File

@@ -1,4 +1,5 @@
Before:
runtime autoload/ale/c.vim
Save g:ale_c_build_dir_names
call ale#test#SetDirectory('/testplugin/test')

View File

@@ -1,4 +1,7 @@
Before:
runtime autoload/ale/c.vim
Save g:ale_c_parse_makefile
Save g:ale_c_always_make
Save b:ale_c_always_make