1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
Before:
call ale#assert#SetUpLinterTest('sh', 'shellcheck')
call ale#test#SetFilename('test.sh')
let b:prefix = ale#path#CdString(ale#path#Simplify(g:dir))
let b:suffix = ' -f gcc -'
After:
unlet! b:is_bash
unlet! b:prefix
unlet! b:suffix
call ale#assert#TearDownLinterTest()
Execute(The default shellcheck command should be correct):
AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck') . b:suffix
Execute(The shellcheck command should accept options):
let b:ale_sh_shellcheck_options = '--foobar'
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix
Execute(The shellcheck command should accept options and exclusions):
let b:ale_sh_shellcheck_options = '--foobar'
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix
Execute(The shellcheck command should include the dialect):
let b:is_bash = 1
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix
Execute(The shellcheck command should use ale_sh_shellcheck_dialect):
let b:ale_sh_shellcheck_dialect = 'ksh93'
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' -s ksh93' . b:suffix
Execute(The shellcheck command should allow unspecified dialect):
let b:ale_sh_shellcheck_dialect = ''
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . b:suffix
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'
AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck')
\ . ' -s bash --foobar -e foo,bar'
\ . b:suffix
Execute(The -x option should be added when the version is new enough):
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\]
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',
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
\]
" We should cache the version check
WithChainResults []
AssertLinter 'shellcheck', [
\ '',
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
\]
Execute(The -x option should not be added when the version is too old):
WithChainResults [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.3.9',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
\]
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\]
Execute(The version check shouldn't be run again for old versions):
WithChainResults [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.3.9',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
\]
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\]
AssertLinter 'shellcheck', [
\ '',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\]
|