2017-08-28 18:16:23 +00:00
|
|
|
Before:
|
2018-07-15 17:24:53 +00:00
|
|
|
call ale#assert#SetUpLinterTest('sh', 'shellcheck')
|
2017-10-25 23:48:51 +00:00
|
|
|
call ale#test#SetFilename('test.sh')
|
|
|
|
|
2018-10-22 13:59:06 +00:00
|
|
|
let b:prefix = ale#path#CdString(ale#Escape(ale#path#Simplify(g:dir)))
|
2017-11-03 22:08:26 +00:00
|
|
|
let b:suffix = ' -f gcc -'
|
2017-10-25 23:48:51 +00:00
|
|
|
|
2017-08-28 18:16:23 +00:00
|
|
|
After:
|
|
|
|
unlet! b:is_bash
|
2017-10-25 23:48:51 +00:00
|
|
|
unlet! b:prefix
|
2018-07-15 17:24:53 +00:00
|
|
|
unlet! b:suffix
|
|
|
|
call ale#assert#TearDownLinterTest()
|
2017-08-28 18:16:23 +00:00
|
|
|
|
|
|
|
Execute(The default shellcheck command should be correct):
|
2018-07-15 17:24:53 +00:00
|
|
|
AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck') . b:suffix
|
2017-08-28 18:16:23 +00:00
|
|
|
|
|
|
|
Execute(The shellcheck command should accept options):
|
|
|
|
let b:ale_sh_shellcheck_options = '--foobar'
|
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
AssertLinter 'shellcheck',
|
|
|
|
\ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix
|
2017-08-28 18:16:23 +00:00
|
|
|
|
|
|
|
Execute(The shellcheck command should accept options and exclusions):
|
|
|
|
let b:ale_sh_shellcheck_options = '--foobar'
|
|
|
|
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
|
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
AssertLinter 'shellcheck',
|
|
|
|
\ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix
|
2017-08-28 18:16:23 +00:00
|
|
|
|
|
|
|
Execute(The shellcheck command should include the dialect):
|
|
|
|
let b:is_bash = 1
|
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
AssertLinter 'shellcheck',
|
|
|
|
\ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix
|
2017-09-22 21:37:12 +00:00
|
|
|
|
|
|
|
Execute(The shellcheck command should include the dialect before options and exclusions):
|
|
|
|
let b:is_bash = 1
|
|
|
|
let b:ale_sh_shellcheck_options = '--foobar'
|
|
|
|
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
|
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck')
|
2017-10-25 23:48:51 +00:00
|
|
|
\ . ' -s bash --foobar -e foo,bar'
|
2018-07-15 17:24:53 +00:00
|
|
|
\ . b:suffix
|
2017-11-03 22:08:26 +00:00
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
Execute(The -x option should be added when the version is new enough):
|
|
|
|
AssertLinter 'shellcheck', [
|
2017-11-03 22:08:26 +00:00
|
|
|
\ ale#Escape('shellcheck') . ' --version',
|
2018-07-15 17:24:53 +00:00
|
|
|
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
|
|
|
|
\]
|
2017-11-03 22:08:26 +00:00
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
WithChainResults [
|
|
|
|
\ 'ShellCheck - shell script analysis tool',
|
|
|
|
\ 'version: 0.4.4',
|
|
|
|
\ 'license: GNU General Public License, version 3',
|
|
|
|
\ 'website: http://www.shellcheck.net',
|
|
|
|
\]
|
|
|
|
AssertLinter 'shellcheck', [
|
|
|
|
\ ale#Escape('shellcheck') . ' --version',
|
2017-11-03 22:08:26 +00:00
|
|
|
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
|
2018-07-15 17:24:53 +00:00
|
|
|
\]
|
2017-11-03 22:08:26 +00:00
|
|
|
|
|
|
|
" We should cache the version check
|
2018-07-15 17:24:53 +00:00
|
|
|
WithChainResults []
|
|
|
|
AssertLinter 'shellcheck', [
|
|
|
|
\ '',
|
2017-11-03 22:08:26 +00:00
|
|
|
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
|
2018-07-15 17:24:53 +00:00
|
|
|
\]
|
2017-11-03 22:08:26 +00:00
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
Execute(The -x option should not be added when the version is too old):
|
|
|
|
WithChainResults [
|
2017-11-03 22:08:26 +00:00
|
|
|
\ 'ShellCheck - shell script analysis tool',
|
2018-07-15 17:24:53 +00:00
|
|
|
\ 'version: 0.3.9',
|
2017-11-03 22:08:26 +00:00
|
|
|
\ 'license: GNU General Public License, version 3',
|
|
|
|
\ 'website: http://www.shellcheck.net',
|
2018-07-15 17:24:53 +00:00
|
|
|
\]
|
|
|
|
AssertLinter 'shellcheck', [
|
|
|
|
\ ale#Escape('shellcheck') . ' --version',
|
2017-11-03 22:08:26 +00:00
|
|
|
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
|
2018-07-15 17:24:53 +00:00
|
|
|
\]
|
2017-11-03 22:08:26 +00:00
|
|
|
|
|
|
|
Execute(The version check shouldn't be run again for old versions):
|
2018-07-15 17:24:53 +00:00
|
|
|
WithChainResults [
|
2017-11-03 22:08:26 +00:00
|
|
|
\ 'ShellCheck - shell script analysis tool',
|
|
|
|
\ 'version: 0.3.9',
|
|
|
|
\ 'license: GNU General Public License, version 3',
|
|
|
|
\ 'website: http://www.shellcheck.net',
|
2018-07-15 17:24:53 +00:00
|
|
|
\]
|
|
|
|
AssertLinter 'shellcheck', [
|
|
|
|
\ ale#Escape('shellcheck') . ' --version',
|
|
|
|
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
|
|
|
|
\]
|
|
|
|
AssertLinter 'shellcheck', [
|
|
|
|
\ '',
|
|
|
|
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
|
|
|
|
\]
|