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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
Before:
Save g:ale_sh_shellcheck_exclusions
Save g:ale_sh_shellcheck_executable
Save g:ale_sh_shellcheck_options
unlet! g:ale_sh_shellcheck_exclusions
unlet! g:ale_sh_shellcheck_executable
unlet! g:ale_sh_shellcheck_options
runtime ale_linters/sh/shellcheck.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('test.sh')
let b:prefix = 'cd ' . ale#Escape(ale#path#Winify(g:dir)) . ' && '
let b:suffix = ' -f gcc -'
After:
Restore
unlet! b:ale_sh_shellcheck_exclusions
unlet! b:ale_sh_shellcheck_executable
unlet! b:ale_sh_shellcheck_options
unlet! b:is_bash
unlet! b:prefix
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The default shellcheck command should be correct):
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
Execute(The shellcheck command should accept options):
let b:ale_sh_shellcheck_options = '--foobar'
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
Execute(The shellcheck command should accept options and exclusions):
let b:ale_sh_shellcheck_options = '--foobar'
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
Execute(The shellcheck command should include the dialect):
let b:is_bash = 1
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
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'
AssertEqual
\ b:prefix
\ . ale#Escape('shellcheck')
\ . ' -s bash --foobar -e foo,bar'
\ . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
Execute(The VersionCheck function should return the --version command):
AssertEqual
\ ale#Escape('shellcheck') . ' --version',
\ ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
let g:ale_sh_shellcheck_executable = 'foobar'
AssertEqual
\ ale#Escape('foobar') . ' --version',
\ ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
Execute(The -x option should be added when the version is new enough):
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.4.4',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
\ ])
" We should cache the version check
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
AssertEqual '', ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
Execute(The version check shouldn't be run again for new versions):
call ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.4.4',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
\])
Execute(The -x option should not be added when the version is too old):
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.3.9',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
\ ])
" We should cache the version check
AssertEqual
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
Execute(The version check shouldn't be run again for old versions):
call ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.3.9',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
\])
AssertEqual '', ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
|