mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-23 18:18:45 +08:00
Add buf linter and fixer (#4128)
* Add buf lint to linters * Add buf format to fixers * Fix test/linter/test_buf_lint.vader * Fix test/fixers/test_buf_format_fixer_callback.vader * Simplify test/test-files/proto/testfile.proto * Add buf-lint alias and rename linter
This commit is contained in:
21
test/fixers/test_buf_format_fixer_callback.vader
Normal file
21
test/fixers/test_buf_format_fixer_callback.vader
Normal file
@@ -0,0 +1,21 @@
|
||||
Before:
|
||||
Save g:ale_proto_buf_format_executable
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_proto_buf_format_executable = 'xxxinvalid'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The buf-format callback should return the correct default values):
|
||||
call ale#test#SetFilename('../test-files/proto/testfile.proto')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid') . ' format %t',
|
||||
\ },
|
||||
\ ale#fixers#buf_format#Fix(bufnr(''))
|
||||
22
test/linter/test_buf_lint.vader
Normal file
22
test/linter/test_buf_lint.vader
Normal file
@@ -0,0 +1,22 @@
|
||||
Before:
|
||||
call ale#assert#SetUpLinterTest('proto', 'buf_lint')
|
||||
call ale#test#SetFilename('test.proto')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The default command should be correct):
|
||||
AssertLinter 'buf',
|
||||
\ ale#Escape('buf')
|
||||
\ . ' lint'
|
||||
\ . ' %s#include_package_files=true'
|
||||
|
||||
Execute(The callback should include any additional options):
|
||||
let b:ale_proto_buf_lint_executable = '/tmp/buf'
|
||||
let b:ale_proto_buf_lint_config = '/tmp/buf.yaml'
|
||||
|
||||
AssertLinter '/tmp/buf',
|
||||
\ ale#Escape('/tmp/buf')
|
||||
\ . ' lint'
|
||||
\ . ' --config=' . ale#Escape('/tmp/buf.yaml')
|
||||
\ . ' %s#include_package_files=true'
|
||||
0
test/test-files/proto/testfile.proto
Normal file
0
test/test-files/proto/testfile.proto
Normal file
Reference in New Issue
Block a user