Skip to content

Commit 594777a

Browse files
committed
Refactor: Allow passing plugin config to goldenWithHaskellDocFormatter
1 parent 74cab28 commit 594777a

File tree

7 files changed

+19
-11
lines changed

7 files changed

+19
-11
lines changed

hls-test-utils/src/Test/Hls.hs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import qualified Data.Aeson as A
4848
import Data.ByteString.Lazy (ByteString)
4949
import Data.Default (def)
5050
import Data.Maybe (fromMaybe)
51+
import qualified Data.Map as M
5152
import qualified Data.Text as T
5253
import qualified Data.Text.Lazy as TL
5354
import qualified Data.Text.Lazy.Encoding as TL
@@ -69,7 +70,7 @@ import Development.IDE.Types.Logger (Logger (Logger),
6970
import Development.IDE.Types.Options
7071
import GHC.IO.Handle
7172
import GHC.Stack (emptyCallStack)
72-
import Ide.Plugin.Config (Config, formattingProvider)
73+
import Ide.Plugin.Config (Config, formattingProvider, PluginConfig, plugins)
7374
import Ide.PluginUtils (idePluginsToPluginDesc,
7475
pluginDescToIdePlugins)
7576
import Ide.Types
@@ -132,16 +133,17 @@ goldenWithHaskellDoc plugin title testDataDir path desc ext act =
132133
goldenWithHaskellDocFormatter
133134
:: PluginDescriptor IdeState
134135
-> String
136+
-> PluginConfig
135137
-> TestName
136138
-> FilePath
137139
-> FilePath
138140
-> FilePath
139141
-> FilePath
140142
-> (TextDocumentIdentifier -> Session ())
141143
-> TestTree
142-
goldenWithHaskellDocFormatter plugin formatter title testDataDir path desc ext act =
144+
goldenWithHaskellDocFormatter plugin formatter conf title testDataDir path desc ext act =
143145
goldenGitDiff title (testDataDir </> path <.> desc <.> ext)
144-
$ runSessionWithServerFormatter plugin formatter testDataDir
146+
$ runSessionWithServerFormatter plugin formatter conf testDataDir
145147
$ TL.encodeUtf8 . TL.fromStrict
146148
<$> do
147149
doc <- openDoc (path <.> ext) "haskell"
@@ -152,11 +154,14 @@ goldenWithHaskellDocFormatter plugin formatter title testDataDir path desc ext a
152154
runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
153155
runSessionWithServer plugin = runSessionWithServer' [plugin] def def fullCaps
154156

155-
runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> FilePath -> Session a -> IO a
156-
runSessionWithServerFormatter plugin formatter =
157+
runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> PluginConfig -> FilePath -> Session a -> IO a
158+
runSessionWithServerFormatter plugin formatter conf =
157159
runSessionWithServer'
158160
[plugin]
159-
def {formattingProvider = T.pack formatter}
161+
def
162+
{ formattingProvider = T.pack formatter
163+
, plugins = M.singleton (T.pack formatter) conf
164+
}
160165
def
161166
fullCaps
162167

plugins/hls-brittany-plugin/test/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tests = testGroup "brittany"
3131
]
3232

3333
brittanyGolden :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
34-
brittanyGolden title path desc = goldenWithHaskellDocFormatter brittanyPlugin "brittany" title testDataDir path desc "hs"
34+
brittanyGolden title path desc = goldenWithHaskellDocFormatter brittanyPlugin "brittany" def title testDataDir path desc "hs"
3535

3636
testDataDir :: FilePath
3737
testDataDir = "test" </> "testdata"

plugins/hls-floskell-plugin/test/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests = testGroup "floskell"
2424
]
2525

2626
goldenWithFloskell :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
27-
goldenWithFloskell title path desc = goldenWithHaskellDocFormatter floskellPlugin "floskell" title testDataDir path desc "hs"
27+
goldenWithFloskell title path desc = goldenWithHaskellDocFormatter floskellPlugin "floskell" def title testDataDir path desc "hs"
2828

2929
testDataDir :: FilePath
3030
testDataDir = "test" </> "testdata"

plugins/hls-fourmolu-plugin/hls-fourmolu-plugin.cabal

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ test-suite tests
4343
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
4444
build-depends:
4545
, base
46+
, aeson
47+
, containers
4648
, filepath
4749
, hls-fourmolu-plugin
50+
, hls-plugin-api
4851
, hls-test-utils ^>=1.2
4952
, lsp-test

plugins/hls-fourmolu-plugin/test/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests = testGroup "fourmolu"
2424
]
2525

2626
goldenWithFourmolu :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
27-
goldenWithFourmolu title path desc = goldenWithHaskellDocFormatter fourmoluPlugin "fourmolu" title testDataDir path desc "hs"
27+
goldenWithFourmolu title path desc = goldenWithHaskellDocFormatter fourmoluPlugin "fourmolu" def title testDataDir path desc "hs"
2828

2929
testDataDir :: FilePath
3030
testDataDir = "test" </> "testdata"

plugins/hls-ormolu-plugin/test/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tests = testGroup "ormolu"
2323
]
2424

2525
goldenWithOrmolu :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
26-
goldenWithOrmolu title path desc = goldenWithHaskellDocFormatter ormoluPlugin "ormolu" title testDataDir path desc "hs"
26+
goldenWithOrmolu title path desc = goldenWithHaskellDocFormatter ormoluPlugin "ormolu" def title testDataDir path desc "hs"
2727

2828
testDataDir :: FilePath
2929
testDataDir = "test" </> "testdata"

plugins/hls-stylish-haskell-plugin/test/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tests = testGroup "stylish-haskell"
2222
]
2323

2424
goldenWithStylishHaskell :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
25-
goldenWithStylishHaskell title fp desc = goldenWithHaskellDocFormatter stylishHaskellPlugin "stylishHaskell" title testDataDir fp desc "hs"
25+
goldenWithStylishHaskell title fp desc = goldenWithHaskellDocFormatter stylishHaskellPlugin "stylishHaskell" def title testDataDir fp desc "hs"
2626

2727
testDataDir :: FilePath
2828
testDataDir = "test" </> "testdata"

0 commit comments

Comments
 (0)