Add some unit tests for extension detection
This commit is contained in:
parent
437f73c001
commit
a504ca6b57
|
@ -484,7 +484,7 @@ checkShebang params (T_Annotation _ list t) =
|
||||||
checkShebang params (T_Script id sb _) = execWriter $ do
|
checkShebang params (T_Script id sb _) = execWriter $ do
|
||||||
unless (shellTypeSpecified params) $ do
|
unless (shellTypeSpecified params) $ do
|
||||||
when (sb == "") $
|
when (sb == "") $
|
||||||
err id 2148 "Tips depend on target shell and yours is unknown. Add a shebang or a .bash, .ksh, .dash extension to the filename."
|
err id 2148 "Tips depend on target shell and yours is unknown. Add a shebang."
|
||||||
when (executableFromShebang sb == "ash") $
|
when (executableFromShebang sb == "ash") $
|
||||||
warn id 2187 "Ash scripts will be checked as Dash. Add '# shellcheck shell=dash' to silence."
|
warn id 2187 "Ash scripts will be checked as Dash. Add '# shellcheck shell=dash' to silence."
|
||||||
unless (null sb) $ do
|
unless (null sb) $ do
|
||||||
|
|
|
@ -244,5 +244,35 @@ prop_sourcePartOfOriginalScript = -- #1181: -x disabled posix warning for 'sourc
|
||||||
|
|
||||||
prop_spinBug1413 = null $ check "fun() {\n# shellcheck disable=SC2188\n> /dev/null\n}\n"
|
prop_spinBug1413 = null $ check "fun() {\n# shellcheck disable=SC2188\n> /dev/null\n}\n"
|
||||||
|
|
||||||
|
prop_deducesTypeFromExtension = null result
|
||||||
|
where
|
||||||
|
result = checkWithSpec [] emptyCheckSpec {
|
||||||
|
csFilename = "file.ksh",
|
||||||
|
csScript = "(( 3.14 ))"
|
||||||
|
}
|
||||||
|
|
||||||
|
prop_deducesTypeFromExtension2 = result == [2079]
|
||||||
|
where
|
||||||
|
result = checkWithSpec [] emptyCheckSpec {
|
||||||
|
csFilename = "file.bash",
|
||||||
|
csScript = "(( 3.14 ))"
|
||||||
|
}
|
||||||
|
|
||||||
|
prop_shExtensionDoesntMatter = result == [2148]
|
||||||
|
where
|
||||||
|
result = checkWithSpec [] emptyCheckSpec {
|
||||||
|
csFilename = "file.sh",
|
||||||
|
csScript = "echo 'hello world'"
|
||||||
|
}
|
||||||
|
|
||||||
|
prop_sourcedFileUsesOriginalShellExtension = result == [2079]
|
||||||
|
where
|
||||||
|
result = checkWithSpec [("file.ksh", "(( 3.14 ))")] emptyCheckSpec {
|
||||||
|
csFilename = "file.bash",
|
||||||
|
csScript = "source file.ksh",
|
||||||
|
csCheckSourced = True
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
runTests = $quickCheckAll
|
runTests = $quickCheckAll
|
||||||
|
|
Loading…
Reference in New Issue