mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-14 22:21:52 +08:00
Fix FindCompileCommands to handle absolute paths in c_build_dir_names
Use ale#path#GetAbsPath to resolve build directory paths, which correctly handles both absolute and relative paths. When the dirname is absolute, derive the project root from the parent of the build directory. Co-authored-by: w0rp <3518142+w0rp@users.noreply.github.com>
This commit is contained in:
33
test/test_c_find_compile_commands.vader
Normal file
33
test/test_c_find_compile_commands.vader
Normal file
@@ -0,0 +1,33 @@
|
||||
Before:
|
||||
Save g:ale_c_build_dir_names
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(FindCompileCommands should find compile_commands.json with relative build dir names):
|
||||
call ale#test#SetFilename('test-files/c/json_project/subdir/dummy')
|
||||
|
||||
let g:ale_c_build_dir_names = ['build']
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/test-files/c/json_project'),
|
||||
\ ale#path#Simplify(g:dir . '/test-files/c/json_project/build/compile_commands.json'),
|
||||
\ ],
|
||||
\ ale#c#FindCompileCommands(bufnr(''))
|
||||
|
||||
Execute(FindCompileCommands should find compile_commands.json with absolute build dir names):
|
||||
call ale#test#SetFilename('test-files/c/json_project/subdir/dummy')
|
||||
|
||||
let g:ale_c_build_dir_names = [ale#path#Simplify(g:dir . '/test-files/c/json_project/build')]
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/test-files/c/json_project'),
|
||||
\ ale#path#Simplify(g:dir . '/test-files/c/json_project/build/compile_commands.json'),
|
||||
\ ],
|
||||
\ ale#c#FindCompileCommands(bufnr(''))
|
||||
Reference in New Issue
Block a user