@@ -17,9 +17,11 @@ module Test.Hls
1717 goldenGitDiff ,
1818 goldenWithHaskellDoc ,
1919 goldenWithHaskellDocFormatter ,
20+ goldenWithCabalDocFormatter ,
2021 def ,
2122 runSessionWithServer ,
2223 runSessionWithServerFormatter ,
24+ runSessionWithCabalServerFormatter ,
2325 runSessionWithServer' ,
2426 waitForProgressDone ,
2527 waitForAllProgressDone ,
@@ -70,6 +72,7 @@ import Development.IDE.Types.Options
7072import GHC.IO.Handle
7173import GHC.Stack (emptyCallStack )
7274import Ide.Plugin.Config (Config , PluginConfig ,
75+ cabalFormattingProvider ,
7376 formattingProvider , plugins )
7477import Ide.PluginUtils (idePluginsToPluginDesc ,
7578 pluginDescToIdePlugins )
@@ -130,15 +133,30 @@ goldenWithHaskellDoc plugin title testDataDir path desc ext act =
130133 act doc
131134 documentContents doc
132135
136+
137+ runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
138+ runSessionWithServer plugin = runSessionWithServer' [plugin] def def fullCaps
139+
140+ runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
141+ runSessionWithServerFormatter plugin formatter conf =
142+ runSessionWithServer'
143+ [plugin]
144+ def
145+ { formattingProvider = T. pack formatter
146+ , plugins = M. singleton (T. pack formatter) conf
147+ }
148+ def
149+ fullCaps
150+
133151goldenWithHaskellDocFormatter
134- :: PluginDescriptor IdeState
135- -> String
152+ :: PluginDescriptor IdeState -- ^ Formatter plugin to be used
153+ -> String -- ^ Name of the formatter to be used
136154 -> PluginConfig
137- -> TestName
138- -> FilePath
139- -> FilePath
140- -> FilePath
141- -> FilePath
155+ -> TestName -- ^ Title of the test
156+ -> FilePath -- ^ Directory of the test data to be used
157+ -> FilePath -- ^ Path to the testdata to be used within the directory
158+ -> FilePath -- ^ Additional suffix to be appended to the output file
159+ -> FilePath -- ^ Extension of the output file
142160 -> (TextDocumentIdentifier -> Session () )
143161 -> TestTree
144162goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc ext act =
@@ -151,15 +169,33 @@ goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc
151169 act doc
152170 documentContents doc
153171
154- runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
155- runSessionWithServer plugin = runSessionWithServer' [plugin] def def fullCaps
172+ goldenWithCabalDocFormatter
173+ :: PluginDescriptor IdeState -- ^ Formatter plugin to be used
174+ -> String -- ^ Name of the formatter to be used
175+ -> PluginConfig
176+ -> TestName -- ^ Title of the test
177+ -> FilePath -- ^ Directory of the test data to be used
178+ -> FilePath -- ^ Path to the testdata to be used within the directory
179+ -> FilePath -- ^ Additional suffix to be appended to the output file
180+ -> FilePath -- ^ Extension of the output file
181+ -> (TextDocumentIdentifier -> Session () )
182+ -> TestTree
183+ goldenWithCabalDocFormatter plugin formatter conf title testDataDir path desc ext act =
184+ goldenGitDiff title (testDataDir </> path <.> desc <.> ext)
185+ $ runSessionWithCabalServerFormatter plugin formatter conf testDataDir
186+ $ TL. encodeUtf8 . TL. fromStrict
187+ <$> do
188+ doc <- openDoc (path <.> ext) " cabal"
189+ void waitForBuildQueue
190+ act doc
191+ documentContents doc
156192
157- runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
158- runSessionWithServerFormatter plugin formatter conf =
193+ runSessionWithCabalServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
194+ runSessionWithCabalServerFormatter plugin formatter conf =
159195 runSessionWithServer'
160196 [plugin]
161197 def
162- { formattingProvider = T. pack formatter
198+ { cabalFormattingProvider = T. pack formatter
163199 , plugins = M. singleton (T. pack formatter) conf
164200 }
165201 def
0 commit comments