@@ -17,9 +17,11 @@ module Test.Hls
17
17
goldenGitDiff ,
18
18
goldenWithHaskellDoc ,
19
19
goldenWithHaskellDocFormatter ,
20
+ goldenWithCabalDocFormatter ,
20
21
def ,
21
22
runSessionWithServer ,
22
23
runSessionWithServerFormatter ,
24
+ runSessionWithCabalServerFormatter ,
23
25
runSessionWithServer' ,
24
26
waitForProgressDone ,
25
27
waitForAllProgressDone ,
@@ -70,6 +72,7 @@ import Development.IDE.Types.Options
70
72
import GHC.IO.Handle
71
73
import GHC.Stack (emptyCallStack )
72
74
import Ide.Plugin.Config (Config , PluginConfig ,
75
+ cabalFormattingProvider ,
73
76
formattingProvider , plugins )
74
77
import Ide.PluginUtils (idePluginsToPluginDesc ,
75
78
pluginDescToIdePlugins )
@@ -130,15 +133,30 @@ goldenWithHaskellDoc plugin title testDataDir path desc ext act =
130
133
act doc
131
134
documentContents doc
132
135
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
+
133
151
goldenWithHaskellDocFormatter
134
- :: PluginDescriptor IdeState
135
- -> String
152
+ :: PluginDescriptor IdeState -- ^ Formatter plugin to be used
153
+ -> String -- ^ Name of the formatter to be used
136
154
-> 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
142
160
-> (TextDocumentIdentifier -> Session () )
143
161
-> TestTree
144
162
goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc ext act =
@@ -151,15 +169,33 @@ goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc
151
169
act doc
152
170
documentContents doc
153
171
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
156
192
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 =
159
195
runSessionWithServer'
160
196
[plugin]
161
197
def
162
- { formattingProvider = T. pack formatter
198
+ { cabalFormattingProvider = T. pack formatter
163
199
, plugins = M. singleton (T. pack formatter) conf
164
200
}
165
201
def
0 commit comments