Skip to content

Commit

Permalink
feat: add tests for shellcheck lints
Browse files Browse the repository at this point in the history
  • Loading branch information
thatRichman committed Dec 10, 2024
1 parent c9ef694 commit 8474ebd
Show file tree
Hide file tree
Showing 8 changed files with 456 additions and 0 deletions.
48 changes: 48 additions & 0 deletions wdl-lint/tests/lints/shellcheck-error/source.errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-error/source.wdl:18:10
18 │ if [ -f "$broken"]
│ ^ SC1073[error]: Couldn't parse this test expression. Fix to allow more checks.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-error/source.wdl:18:15
18 │ if [ -f "$broken"]
│ ^ SC1019[error]: Expected this to be an argument to the unary condition.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-error/source.wdl:18:25
18 │ if [ -f "$broken"]
│ ^ SC1020[error]: You need a space before the ].
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-error/source.wdl:37:10
37 │ if [ -f "$broken"]
│ ^ SC1073[error]: Couldn't parse this test expression. Fix to allow more checks.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-error/source.wdl:37:15
37 │ if [ -f "$broken"]
│ ^ SC1019[error]: Expected this to be an argument to the unary condition.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-error/source.wdl:37:25
37 │ if [ -f "$broken"]
│ ^ SC1020[error]: You need a space before the ].
= fix: address the diagnostics as recommended in the message

43 changes: 43 additions & 0 deletions wdl-lint/tests/lints/shellcheck-error/source.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands
## This is a test of having shellcheck error lints
version 1.1

task test1 {
meta {}

parameter_meta {}

input {
Int placeholder
}

command <<<
somecommand.py [[ -f $broken_test]]
if [ -f "$broken"]
>>>

output {}

runtime {}
}

task test2 {
meta {}

parameter_meta {}

input {
Int placeholder
}

command {
somecommand.py [[ -f $broken_test]]
if [ -f "$broken"]
}

output {}

runtime {}
}
Empty file.
54 changes: 54 additions & 0 deletions wdl-lint/tests/lints/shellcheck-ok/source.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands
## This is a test of having no shellcheck lints
version 1.1

task test1 {
meta {}

parameter_meta {}

input {
Boolean i_quote_my_shellvars
Int placeholder
}

command <<<
set -eo pipefail

echo "$placeholder"

if [[ "$i_quote_my_shellvars" ]]; then
echo "shellcheck will be happy"
fi
>>>

output {}

runtime {}
}

task test2 {
meta {}

parameter_meta {}

input {
Int placeholder
}

command {
set -eo pipefail

echo "$placeholder"

if [[ "$I_quote_my_shellvars" ]]; then
echo "all is well"
fi
}

output {}

runtime {}
}
32 changes: 32 additions & 0 deletions wdl-lint/tests/lints/shellcheck-style/source.errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-style/source.wdl:17:7
17 │ [[ ]]
│ ^^^ SC2212[style]: Use 'false' instead of empty [/[[ conditionals.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-style/source.wdl:18:9
18 │ [ true ]
│ ^^^^ SC2160[style]: Instead of '[ true ]', just use 'true'.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-style/source.wdl:36:7
36 │ [[ ]]
│ ^^^ SC2212[style]: Use 'false' instead of empty [/[[ conditionals.
= fix: address the diagnostics as recommended in the message

note[CommandSectionShellCheck]: `shellcheck` reported the following diagnostic
┌─ tests/lints/shellcheck-style/source.wdl:37:9
37 │ [ true ]
│ ^^^^ SC2160[style]: Instead of '[ true ]', just use 'true'.
= fix: address the diagnostics as recommended in the message

43 changes: 43 additions & 0 deletions wdl-lint/tests/lints/shellcheck-style/source.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#@ except: DescriptionMissing, RuntimeSectionKeys, MatchingParameterMeta, NoCurlyCommands
## This is a test of having shellcheck style lints
version 1.1

task test1 {
meta {}

parameter_meta {}

input {
Int placeholder
}

command <<<
[[ ]]
[ true ]
>>>

output {}

runtime {}
}

task test2 {
meta {}

parameter_meta {}

input {
Int placeholder
}

command {
[[ ]]
[ true ]
}

output {}

runtime {}
}
Loading

0 comments on commit 8474ebd

Please sign in to comment.