@@ -3,6 +3,9 @@ module Main
3
3
( main
4
4
) where
5
5
6
+ import Data.Aeson
7
+ import Data.Functor
8
+ import Ide.Plugin.Config
6
9
import qualified Ide.Plugin.Fourmolu as Fourmolu
7
10
import Language.LSP.Test
8
11
import Language.LSP.Types
@@ -16,15 +19,21 @@ fourmoluPlugin :: PluginDescriptor IdeState
16
19
fourmoluPlugin = Fourmolu. descriptor " fourmolu"
17
20
18
21
tests :: TestTree
19
- tests = testGroup " fourmolu"
20
- [ goldenWithFourmolu " formats correctly" " Fourmolu" " formatted" $ \ doc -> do
21
- formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing )
22
- , goldenWithFourmolu " formats imports correctly" " Fourmolu" " formatted" $ \ doc -> do
23
- formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing )
24
- ]
22
+ tests =
23
+ testGroup " fourmolu" $
24
+ [False , True ] <&> \ cli ->
25
+ testGroup
26
+ (if cli then " cli" else " lib" )
27
+ [ goldenWithFourmolu cli " formats correctly" " Fourmolu" " formatted" $ \ doc -> do
28
+ formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing )
29
+ , goldenWithFourmolu cli " formats imports correctly" " Fourmolu" " formatted" $ \ doc -> do
30
+ formatDoc doc (FormattingOptions 4 True Nothing Nothing Nothing )
31
+ ]
25
32
26
- goldenWithFourmolu :: TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session () ) -> TestTree
27
- goldenWithFourmolu title path desc = goldenWithHaskellDocFormatter fourmoluPlugin " fourmolu" def title testDataDir path desc " hs"
33
+ goldenWithFourmolu :: Bool -> TestName -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session () ) -> TestTree
34
+ goldenWithFourmolu cli title path desc = goldenWithHaskellDocFormatter fourmoluPlugin " fourmolu" conf title testDataDir path desc " hs"
35
+ where
36
+ conf = def{plcConfig = (\ (Object obj) -> obj) $ object [" cli" .= cli]}
28
37
29
38
testDataDir :: FilePath
30
39
testDataDir = " test" </> " testdata"
0 commit comments