This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
ale/test/command_callback/test_checkstyle_command_callback.vader
Horacio Sanson 8fbcba0091 Fix 2913 - checkstyle config file ignored.
If checkstyle is configured with custom options that contain "-c" then
the checkstyle config file option is ignored. This PR modifies the
regular expression when creating the checkstyle command to avoid this.
2019-11-27 23:19:44 +09:00

72 lines
2.4 KiB
Text

Before:
call ale#assert#SetUpLinterTest('java', 'checkstyle')
call ale#test#SetFilename('dummy.java')
After:
call ale#assert#TearDownLinterTest()
Execute(The checkstyle callback should return the correct default value):
AssertLinter 'checkstyle',
\ ale#Escape('checkstyle')
\ . ' -c ' . ale#Escape('/google_checks.xml')
\ . ' %s'
Execute(The checkstyle executable should be configurable):
let b:ale_java_checkstyle_executable = 'foobar'
AssertLinter 'foobar',
\ ale#Escape('foobar')
\ . ' -c ' . ale#Escape('/google_checks.xml')
\ . ' %s'
Execute(Custom options should be supported):
let b:ale_java_checkstyle_options = '--foobar -cp -classpath /path/to/checkstyle-8.7-all.jar'
AssertLinter 'checkstyle',
\ ale#Escape('checkstyle')
\ . ' --foobar -cp -classpath /path/to/checkstyle-8.7-all.jar'
\ . ' -c ' . ale#Escape('/google_checks.xml')
\ . ' %s'
Execute(configuration files set in _config should be supported):
let b:ale_java_checkstyle_config = ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml')
AssertLinter 'checkstyle',
\ ale#Escape('checkstyle')
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml'))
\ . ' %s'
Execute(configuration files set in _options should be preferred over _config):
let b:ale_java_checkstyle_config = '/foo.xml'
let b:ale_java_checkstyle_options = '-c /bar.xml'
AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' -c /bar.xml %s'
let b:ale_java_checkstyle_options = '-x -c /bar.xml'
AssertLinter 'checkstyle', ale#Escape('checkstyle') . ' -x -c /bar.xml %s'
Execute(google_checks.xml should be used by default):
call ale#test#SetFilename('checkstyle_paths/test.java')
AssertLinter 'checkstyle',
\ ale#Escape('checkstyle')
\ . ' -c ' . ale#Escape('/google_checks.xml')
\ . ' %s'
Execute(Other relative paths should be supported):
let b:ale_java_checkstyle_config = 'checkstyle_paths/other_config.xml'
AssertLinter 'checkstyle',
\ ale#Escape('checkstyle')
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml'))
\ . ' %s'
call ale#test#SetFilename('checkstyle_paths/test.java')
let b:ale_java_checkstyle_config = 'other_config.xml'
AssertLinter 'checkstyle',
\ ale#Escape('checkstyle')
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/checkstyle_paths/other_config.xml'))
\ . ' %s'