mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 13:31:36 -07:00
Preliminary support for sourced files.
This commit is contained in:
parent
0dd61b65d8
commit
f31c8bd3a3
5 changed files with 203 additions and 28 deletions
|
@ -81,7 +81,7 @@ checkScript sys spec = do
|
|||
}
|
||||
|
||||
getErrors sys spec =
|
||||
map getCode . crComments $
|
||||
sort . map getCode . crComments $
|
||||
runIdentity (checkScript sys spec)
|
||||
where
|
||||
getCode (PositionedComment _ (Comment _ code _)) = code
|
||||
|
@ -124,5 +124,45 @@ prop_optionDisablesIssue2 =
|
|||
csExcludedWarnings = [2148, 1037]
|
||||
}
|
||||
|
||||
prop_failsWhenNotSourcing =
|
||||
[1091, 2154] == getErrors
|
||||
(mockedSystemInterface [])
|
||||
emptyCheckSpec {
|
||||
csScript = "source lob; echo \"$bar\"",
|
||||
csExcludedWarnings = [2148]
|
||||
}
|
||||
|
||||
prop_worksWhenSourcing =
|
||||
null $ getErrors
|
||||
(mockedSystemInterface [("lib", "bar=1")])
|
||||
emptyCheckSpec {
|
||||
csScript = "source lib; echo \"$bar\"",
|
||||
csExcludedWarnings = [2148]
|
||||
}
|
||||
|
||||
prop_worksWhenDotting =
|
||||
null $ getErrors
|
||||
(mockedSystemInterface [("lib", "bar=1")])
|
||||
emptyCheckSpec {
|
||||
csScript = ". lib; echo \"$bar\"",
|
||||
csExcludedWarnings = [2148]
|
||||
}
|
||||
|
||||
prop_noInfiniteSourcing =
|
||||
[] == getErrors
|
||||
(mockedSystemInterface [("lib", "source lib")])
|
||||
emptyCheckSpec {
|
||||
csScript = "source lib",
|
||||
csExcludedWarnings = [2148]
|
||||
}
|
||||
|
||||
prop_canSourceBadSyntax =
|
||||
[1094, 2086] == getErrors
|
||||
(mockedSystemInterface [("lib", "for f; do")])
|
||||
emptyCheckSpec {
|
||||
csScript = "source lib; echo $1",
|
||||
csExcludedWarnings = [2148]
|
||||
}
|
||||
|
||||
return []
|
||||
runTests = $quickCheckAll
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue