Skip to content

Commit b6f2e34

Browse files
committed
Fix formatter tests
1 parent c83ad20 commit b6f2e34

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Test.Hls
1313
defaultTestRunner,
1414
goldenGitDiff,
1515
goldenWithHaskellDoc,
16+
goldenWithHaskellDocFormatter,
1617
def,
1718
runSessionWithServer,
1819
runSessionWithServerFormatter,
@@ -90,6 +91,25 @@ goldenWithHaskellDoc plugin title testDataDir path desc ext act =
9091
act doc
9192
documentContents doc
9293

94+
goldenWithHaskellDocFormatter
95+
:: PluginDescriptor IdeState
96+
-> String
97+
-> TestName
98+
-> FilePath
99+
-> FilePath
100+
-> FilePath
101+
-> FilePath
102+
-> (TextDocumentIdentifier -> Session ())
103+
-> TestTree
104+
goldenWithHaskellDocFormatter plugin formatter title testDataDir path desc ext act =
105+
goldenGitDiff title (testDataDir </> path <.> desc <.> ext)
106+
$ runSessionWithServerFormatter plugin formatter testDataDir
107+
$ TL.encodeUtf8 . TL.fromStrict
108+
<$> do
109+
doc <- openDoc (path <.> ext) "haskell"
110+
act doc
111+
documentContents doc
112+
93113
runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
94114
runSessionWithServer plugin = runSessionWithServer' [plugin] def def fullCaps
95115

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 = goldenWithHaskellDoc brittanyPlugin title testDataDir path desc "hs"
34+
brittanyGolden title path desc = goldenWithHaskellDocFormatter brittanyPlugin "brittany" 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 = goldenWithHaskellDoc floskellPlugin title testDataDir path desc "hs"
27+
goldenWithFloskell title path desc = goldenWithHaskellDocFormatter floskellPlugin "floskell" title testDataDir path desc "hs"
2828

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

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 = goldenWithHaskellDoc fourmoluPlugin title testDataDir path desc "hs"
27+
goldenWithFourmolu title path desc = goldenWithHaskellDocFormatter fourmoluPlugin "fourmolu" title testDataDir path desc "hs"
2828

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

plugins/hls-fourmolu-plugin/test/testdata/Fourmolu.formatted.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Format where
1+
module Fourmolu where
22

33
import Data.List
44

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 = goldenWithHaskellDoc ormoluPlugin title testDataDir path desc "hs"
26+
goldenWithOrmolu title path desc = goldenWithHaskellDocFormatter ormoluPlugin "ormolu" title testDataDir path desc "hs"
2727

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

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

Lines changed: 2 additions & 2 deletions
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 = goldenWithHaskellDoc stylishHaskellPlugin title testDataDir fp desc "hs"
25+
goldenWithStylishHaskell title fp desc = goldenWithHaskellDocFormatter stylishHaskellPlugin "stylishHaskell" title testDataDir fp desc "hs"
2626

2727
testDataDir :: FilePath
28-
testDataDir = "test" </> "data"
28+
testDataDir = "test" </> "testdata"

0 commit comments

Comments
 (0)