@@ -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,7 +72,7 @@ import Development.IDE.Types.Options
7072import GHC.IO.Handle
7173import GHC.Stack (emptyCallStack )
7274import Ide.Plugin.Config (Config , PluginConfig ,
73- formattingProvider , plugins )
75+ cabalFormattingProvider , formattingProvider , plugins )
7476import Ide.PluginUtils (idePluginsToPluginDesc ,
7577 pluginDescToIdePlugins )
7678import Ide.Types
@@ -130,15 +132,30 @@ goldenWithHaskellDoc plugin title testDataDir path desc ext act =
130132 act doc
131133 documentContents doc
132134
135+
136+ runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
137+ runSessionWithServer plugin = runSessionWithServer' [plugin] def def fullCaps
138+
139+ runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
140+ runSessionWithServerFormatter plugin formatter conf =
141+ runSessionWithServer'
142+ [plugin]
143+ def
144+ { formattingProvider = T. pack formatter
145+ , plugins = M. singleton (T. pack formatter) conf
146+ }
147+ def
148+ fullCaps
149+
133150goldenWithHaskellDocFormatter
134- :: PluginDescriptor IdeState
135- -> String
151+ :: PluginDescriptor IdeState -- ^ Formatter plugin to be used
152+ -> String -- ^ Name of the formatter to be used
136153 -> PluginConfig
137- -> TestName
138- -> FilePath
139- -> FilePath
140- -> FilePath
141- -> FilePath
154+ -> TestName -- ^ Title of the test
155+ -> FilePath -- ^ Directory of the test data to be used
156+ -> FilePath -- ^ Path to the testdata to be used within the directory
157+ -> FilePath -- ^ Additional suffix to be appended to the output file
158+ -> FilePath -- ^ Extension of the output file
142159 -> (TextDocumentIdentifier -> Session () )
143160 -> TestTree
144161goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc ext act =
@@ -151,15 +168,33 @@ goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc
151168 act doc
152169 documentContents doc
153170
154- runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
155- runSessionWithServer plugin = runSessionWithServer' [plugin] def def fullCaps
171+ goldenWithCabalDocFormatter
172+ :: PluginDescriptor IdeState -- ^ Formatter plugin to be used
173+ -> String -- ^ Name of the formatter to be used
174+ -> PluginConfig
175+ -> TestName -- ^ Title of the test
176+ -> FilePath -- ^ Directory of the test data to be used
177+ -> FilePath -- ^ Path to the testdata to be used within the directory
178+ -> FilePath -- ^ Additional suffix to be appended to the output file
179+ -> FilePath -- ^ Extension of the output file
180+ -> (TextDocumentIdentifier -> Session () )
181+ -> TestTree
182+ goldenWithCabalDocFormatter plugin formatter conf title testDataDir path desc ext act =
183+ goldenGitDiff title (testDataDir </> path <.> desc <.> ext)
184+ $ runSessionWithCabalServerFormatter plugin formatter conf testDataDir
185+ $ TL. encodeUtf8 . TL. fromStrict
186+ <$> do
187+ doc <- openDoc (path <.> ext) " cabal"
188+ void waitForBuildQueue
189+ act doc
190+ documentContents doc
156191
157- runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
158- runSessionWithServerFormatter plugin formatter conf =
192+ runSessionWithCabalServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
193+ runSessionWithCabalServerFormatter plugin formatter conf =
159194 runSessionWithServer'
160195 [plugin]
161196 def
162- { formattingProvider = T. pack formatter
197+ { cabalFormattingProvider = T. pack formatter
163198 , plugins = M. singleton (T. pack formatter) conf
164199 }
165200 def
0 commit comments