mirror of
https://github.com/dense-analysis/ale
synced 2025-01-01 03:02:06 +00:00
bf1c30f585
cmake-format added support for reading from/outputting to stdin/out as of v0.3.6, released 2018-04-10 (commit 2e2aff2) [0]. Reading from stdin is preferable over reading from a temporary file because when given a concrete file cmake-format will look for its config file (.cmake-format.py or similar) in the parent directories of the provided file. If the temporary file is off in a tmpdir somewhere (e.g., /tmp on *nix), cmake-format will almost certainly not come across the user's intended format configuration file, making it appear that cmake-format is ignoring the config file. If cmake-format reads from stdin, though, it'll look for its config file in its current working directory and its parent directories, in a similar manner to clang-format. This has a much higher chance of running across the intended config file. [0]: https://github.com/cheshirekow/cmake_format/releases/tag/v0.3.6 Co-authored-by: Alex Wang <ts826848@gmail.com>
37 lines
994 B
Plaintext
37 lines
994 B
Plaintext
Before:
|
|
Save g:ale_cmake_cmakeformat_executable
|
|
Save g:ale_cmake_cmakeformat_options
|
|
|
|
" Use an invalid global executable, so we don't match it.
|
|
let g:ale_cmake_cmakeformat_executable = 'xxxinvalid'
|
|
let g:ale_cmake_cmakeformat_options = ''
|
|
|
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
|
|
|
After:
|
|
Restore
|
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
Execute(The cmakeformat callback should return the correct default values):
|
|
call ale#test#SetFilename('../cmake_files/CMakeList.txt')
|
|
|
|
AssertEqual
|
|
\ {
|
|
\ 'command': ale#Escape('xxxinvalid')
|
|
\ . ' -'
|
|
\ },
|
|
\ ale#fixers#cmakeformat#Fix(bufnr(''))
|
|
|
|
Execute(The cmakeformat callback should include custom cmakeformat options):
|
|
let g:ale_cmake_cmakeformat_options = "-r '(a) -> a'"
|
|
call ale#test#SetFilename('../cmake_files/CMakeList.txt')
|
|
|
|
AssertEqual
|
|
\ {
|
|
\ 'command': ale#Escape('xxxinvalid')
|
|
\ . ' ' . g:ale_cmake_cmakeformat_options
|
|
\ . ' -',
|
|
\ },
|
|
\ ale#fixers#cmakeformat#Fix(bufnr(''))
|