Skip to content

Commit 2d506c4

Browse files
committed
Fix hie-bios functional tests
1 parent e1d057e commit 2d506c4

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

test/functional/HieBios.hs

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,22 @@ import Control.Lens ((^.))
55
import Control.Monad.IO.Class
66
import qualified Data.Text as T
77
import qualified Language.LSP.Protocol.Lens as L
8-
import System.FilePath ((</>))
98
import Test.Hls
109
import Test.Hls.Command
1110

12-
1311
tests :: TestTree
14-
tests = testGroup "hie-bios" [
15-
testCase "loads modules inside main-is" $ do
16-
writeFile (hieBiosErrorPath </> "hie.yaml") ""
17-
runSession hlsCommand fullCaps "test/testdata/hieBiosMainIs" $ do
18-
doc <- openDoc "Main.hs" "haskell"
19-
Just mainHoverText <- getHover doc (Position 3 1)
20-
let hoverContents = mainHoverText ^. L.contents
21-
case hoverContents of
22-
(InL (MarkupContent _ x)) -> do
23-
liftIO $ "main :: IO ()" `T.isInfixOf` x
24-
@? "found hover text for main"
25-
_ -> error $ "Unexpected hover contents: " ++ show hoverContents
12+
tests = testGroup "hie-bios"
13+
[ testCase "loads main-is module" $ do
14+
runSession hlsCommand fullCaps "test/testdata/hieBiosMainIs" $ do
15+
_ <- openDoc "Main.hs" "haskell"
16+
(diag:_) <- waitForDiagnostics
17+
liftIO $ "Top-level binding with no type signature:" `T.isInfixOf` (diag ^. L.message)
18+
@? "Expected missing top-level binding diagnostic"
2619

27-
, expectFailBecause "hie-bios 0.11 has poor error messages" $ testCase "reports errors in hie.yaml" $ do
28-
writeFile (hieBiosErrorPath </> "hie.yaml") ""
29-
runSession hlsCommand fullCaps hieBiosErrorPath $ do
30-
_ <- openDoc "Foo.hs" "haskell"
31-
(diag:_) <- waitForDiagnostics
32-
liftIO $ "Expected a cradle: key containing the preferences" `T.isInfixOf` (diag ^. L.message)
33-
@? "Error reported"
34-
]
35-
where
36-
hieBiosErrorPath = "test/testdata/hieBiosError"
20+
, expectFailBecause "hie-bios 0.11 has poor error messages" $ testCase "reports errors in hie.yaml" $ do
21+
runSession hlsCommand fullCaps "test/testdata/hieBiosError" $ do
22+
_ <- openDoc "Foo.hs" "haskell"
23+
(diag:_) <- waitForDiagnostics
24+
liftIO $ "Expected a cradle: key containing the preferences" `T.isInfixOf` (diag ^. L.message)
25+
@? "Expected missing top-level binding diagnostic"
26+
]

test/testdata/hieBiosMainIs/Main.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module Main where
1+
module Main (main) where
22

33
main :: IO ()
4-
main = putStrLn "Hello, Haskell!"
4+
main = print foo
5+
6+
foo = 5 :: Int
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

test/testdata/hieBiosMainIs/hieBiosMainIs.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ version: 0.1.0.0
44
build-type: Simple
55
executable hieBiosMainIs
66
main-is: Main.hs
7-
build-depends: base >=4.12 && <4.13
7+
build-depends: base
88
default-language: Haskell2010
9+
ghc-options: -Wall

0 commit comments

Comments
 (0)