summaryrefslogtreecommitdiff
path: root/test/test_shell_detection.vader
diff options
context:
space:
mode:
authorHoracio Sanson <hsanson@gmail.com>2020-11-22 05:49:31 +0900
committerGitHub <noreply@github.com>2020-11-21 20:49:31 +0000
commit5458a1b29167b1fefde5fb6545e371a9d77ca36e (patch)
tree6331afad97107a9199f167cadb33a6a582d8ff65 /test/test_shell_detection.vader
parentb4550f361bc0d8d0cce81ecc02c82167b6df0738 (diff)
downloadale-5458a1b29167b1fefde5fb6545e371a9d77ca36e.zip
Fix 3103 - add shellcheck shell directive detection. (#3216)
* Fix 3103 - add shellcheck shell directive detection. Searches for shellcheck shell directive to detect dialects for scripts that do not have shebang. * Change order of detection of shellcheck dialect In a situation where the filetype can be wrong (example: something.sh which is written in bash dialect) and has no hash-bang (since it is meant to be sourced) then the override specified within the script will be ignored. It probably is the most right thing to do if the script author has added a specific directive; it should trump everything else. Co-authored-by: Horacio Sanson <horacio@allm.inc> Co-authored-by: Dino Korah <dino.korah@redmatter.com>
Diffstat (limited to 'test/test_shell_detection.vader')
-rw-r--r--test/test_shell_detection.vader48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/test_shell_detection.vader b/test/test_shell_detection.vader
index 697054d0..11d801c3 100644
--- a/test/test_shell_detection.vader
+++ b/test/test_shell_detection.vader
@@ -127,3 +127,51 @@ Execute(The dash dialect should be used for the shell and the base function):
Execute(dash should be used for shellcheck):
AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a Bash shellcheck shell directive):
+ # shellcheck shell=bash
+
+Execute(bash dialect should be detected appropriately):
+ AssertEqual 'bash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a sh shellcheck shell directive):
+ #shellcheck shell=sh
+
+Execute(sh dialect should be detected appropriately):
+ AssertEqual 'sh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a tcsh shellcheck shell directive):
+ # shellcheck shell=tcsh
+
+Execute(tcsh dialect should be detected appropriately):
+ AssertEqual 'tcsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a zsh shellcheck shell directive):
+ # shellcheck shell=zsh
+
+Execute(zsh dialect should be detected appropriately):
+ AssertEqual 'zsh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a csh shellcheck shell directive):
+ # shellcheck shell=csh
+
+Execute(zsh dialect should be detected appropriately):
+ AssertEqual 'csh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a ksh shellcheck shell directive):
+ # shellcheck shell=ksh
+
+Execute(ksh dialect should be detected appropriately):
+ AssertEqual 'ksh', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a dash shellcheck shell directive):
+ # shellcheck shell=dash
+
+Execute(dash dialect should be detected appropriately):
+ AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))
+
+Given(A file with a ash shellcheck shell directive):
+ # shellcheck shell=ash
+
+Execute(dash dialect should be detected for ash that shellcheck does not support):
+ AssertEqual 'dash', ale#handlers#shellcheck#GetDialectArgument(bufnr(''))