Skip to content

Commit

Permalink
Add a newSystemInterface to go with the rest of the new* constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
koalaman committed Aug 13, 2023
1 parent d18b255 commit 90d3172
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shellcheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ ioInterface options files = do
inputs <- mapM normalize files
cache <- newIORef emptyCache
configCache <- newIORef ("", Nothing)
return SystemInterface {
return (newSystemInterface :: SystemInterface IO) {
siReadFile = get cache inputs,
siFindSource = findSourceFile inputs (sourcePaths options),
siGetConfig = getConfig configCache
Expand Down
15 changes: 12 additions & 3 deletions src/ShellCheck/Interface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ module ShellCheck.Interface
, ColorOption(ColorAuto, ColorAlways, ColorNever)
, TokenComment(tcId, tcComment, tcFix)
, emptyCheckResult
, newParseResult
, newAnalysisSpec
, newAnalysisResult
, newAnalysisSpec
, newFormatterOptions
, newParseResult
, newPosition
, newSystemInterface
, newTokenComment
, mockedSystemInterface
, mockRcFile
Expand Down Expand Up @@ -135,6 +136,14 @@ newParseSpec = ParseSpec {
psShellTypeOverride = Nothing
}

newSystemInterface :: Monad m => SystemInterface m
newSystemInterface =
SystemInterface {
siReadFile = \_ _ -> return $ Left "Not implemented",
siFindSource = \_ _ _ name -> return name,
siGetConfig = \_ -> return Nothing
}

-- Parser input and output
data ParseSpec = ParseSpec {
psFilename :: String,
Expand Down Expand Up @@ -311,7 +320,7 @@ data ColorOption =

-- For testing
mockedSystemInterface :: [(String, String)] -> SystemInterface Identity
mockedSystemInterface files = SystemInterface {
mockedSystemInterface files = (newSystemInterface :: SystemInterface Identity) {
siReadFile = rf,
siFindSource = fs,
siGetConfig = const $ return Nothing
Expand Down

0 comments on commit 90d3172

Please sign in to comment.