]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_shell_detection.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / test_shell_detection.vader
1 Before:
2   runtime ale_linters/sh/shell.vim
3   runtime ale_linters/sh/shellcheck.vim
4
5 After:
6   call ale#linter#Reset()
7
8   unlet! b:is_bash
9   unlet! b:is_sh
10   unlet! b:is_kornshell
11
12 Given(A file with a Bash hashbang):
13   #!/bin/bash
14
15 Execute(/bin/bash should be detected appropriately):
16   AssertEqual 'bash', ale#handlers#sh#GetShellType(bufnr(''))
17   AssertEqual 'bash', ale_linters#sh#shell#GetExecutable(bufnr(''))
18   AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
19
20 Given(A file with /bin/sh):
21   #!/usr/bin/env sh -eu --foobar
22
23 Execute(/bin/sh should be detected appropriately):
24   AssertEqual 'sh', ale#handlers#sh#GetShellType(bufnr(''))
25   AssertEqual 'sh', ale_linters#sh#shell#GetExecutable(bufnr(''))
26   AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
27
28 Given(A file with bash as an argument to env):
29   #!/usr/bin/env bash
30
31 Execute(/usr/bin/env bash should be detected appropriately):
32   AssertEqual 'bash', ale#handlers#sh#GetShellType(bufnr(''))
33   AssertEqual 'bash', ale_linters#sh#shell#GetExecutable(bufnr(''))
34   AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
35
36 Given(A file with a tcsh hash bang and arguments):
37   #!/usr/bin/env tcsh -eu --foobar
38
39 Execute(tcsh should be detected appropriately):
40   AssertEqual 'tcsh', ale#handlers#sh#GetShellType(bufnr(''))
41   AssertEqual 'tcsh', ale_linters#sh#shell#GetExecutable(bufnr(''))
42   AssertEqual 'tcsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
43
44 Given(A file with a zsh hash bang and arguments):
45   #!/usr/bin/env zsh -eu --foobar
46
47 Execute(zsh should be detected appropriately):
48   AssertEqual 'zsh', ale#handlers#sh#GetShellType(bufnr(''))
49   AssertEqual 'zsh', ale_linters#sh#shell#GetExecutable(bufnr(''))
50   AssertEqual 'zsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
51
52 Given(A file with a csh hash bang and arguments):
53   #!/usr/bin/env csh -eu --foobar
54
55 Execute(csh should be detected appropriately):
56   AssertEqual 'csh', ale#handlers#sh#GetShellType(bufnr(''))
57   AssertEqual 'csh', ale_linters#sh#shell#GetExecutable(bufnr(''))
58   AssertEqual 'csh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
59
60 Given(A file with a ksh hashbang):
61   #!/bin/ksh
62
63 Execute(/bin/ksh should be detected appropriately):
64   AssertEqual 'ksh', ale#handlers#sh#GetShellType(bufnr(''))
65   AssertEqual 'ksh', ale_linters#sh#shell#GetExecutable(bufnr(''))
66   AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
67
68 Given(A file with a ksh as an argument to env):
69   #!/usr/bin/env ksh
70
71 Execute(ksh should be detected appropriately):
72   AssertEqual 'ksh', ale#handlers#sh#GetShellType(bufnr(''))
73   AssertEqual 'ksh', ale_linters#sh#shell#GetExecutable(bufnr(''))
74   AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
75
76 Given(A file with a sh hash bang and arguments):
77   #!/usr/bin/env sh -eu --foobar
78
79 Execute(sh should be detected appropriately):
80   AssertEqual 'sh', ale#handlers#sh#GetShellType(bufnr(''))
81   AssertEqual 'sh', ale_linters#sh#shell#GetExecutable(bufnr(''))
82   AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
83
84 Given(A file without a hashbang):
85
86 Execute(The bash dialect should be used for shellcheck if b:is_bash is 1):
87   let b:is_bash = 1
88
89   AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
90
91 Execute(The sh dialect should be used for shellcheck if b:is_sh is 1):
92   let b:is_sh = 1
93
94   AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
95
96 Execute(The ksh dialect should be used for shellcheck if b:is_kornshell is 1):
97   let b:is_kornshell = 1
98
99   AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
100
101 Execute(The filetype should be used as the default shell type when there is no hashbang line):
102   set filetype=zsh
103   AssertEqual 'zsh', ale#handlers#sh#GetShellType(bufnr(''))
104
105   set filetype=tcsh
106   AssertEqual 'tcsh', ale#handlers#sh#GetShellType(bufnr(''))
107
108   set filetype=python
109   AssertEqual '', ale#handlers#sh#GetShellType(bufnr(''))
110
111 Given(A file with /bin/ash):
112   #!/bin/ash
113
114 Execute(The ash dialect should be used for the shell and the base function):
115   AssertEqual 'ash', ale#handlers#sh#GetShellType(bufnr(''))
116   AssertEqual 'ash', ale_linters#sh#shell#GetExecutable(bufnr(''))
117
118 Execute(dash should be used for shellcheck, which has no ash dialect):
119   AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
120
121 Given(A file with /bin/dash):
122   #!/bin/dash
123
124 Execute(The dash dialect should be used for the shell and the base function):
125   AssertEqual 'dash', ale#handlers#sh#GetShellType(bufnr(''))
126   AssertEqual 'dash', ale_linters#sh#shell#GetExecutable(bufnr(''))
127
128 Execute(dash should be used for shellcheck):
129   AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
130
131 Given(A file with a Bash shellcheck shell directive):
132   # shellcheck shell=bash
133
134 Execute(bash dialect should be detected appropriately):
135   AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
136
137 Given(A file with a sh shellcheck shell directive):
138   #shellcheck   shell=sh
139
140 Execute(sh dialect should be detected appropriately):
141   AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
142
143 Given(A file with a tcsh shellcheck shell directive):
144   #   shellcheck   shell=tcsh
145
146 Execute(tcsh dialect should be detected appropriately):
147   AssertEqual 'tcsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
148
149 Given(A file with a zsh shellcheck shell directive):
150   #   shellcheck shell=zsh
151
152 Execute(zsh dialect should be detected appropriately):
153   AssertEqual 'zsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
154
155 Given(A file with a csh shellcheck shell directive):
156   # shellcheck shell=csh
157
158 Execute(zsh dialect should be detected appropriately):
159   AssertEqual 'csh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
160
161 Given(A file with a ksh shellcheck shell directive):
162   # shellcheck shell=ksh
163
164 Execute(ksh dialect should be detected appropriately):
165   AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
166
167 Given(A file with a dash shellcheck shell directive):
168   # shellcheck shell=dash
169
170 Execute(dash dialect should be detected appropriately):
171   AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
172
173 Given(A file with a ash shellcheck shell directive):
174   # shellcheck shell=ash
175
176 Execute(dash dialect should be detected for ash that shellcheck does not support):
177   AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))