Skip to content

Commit 552be36

Browse files
authored
Merge pull request #3814 from fendor/fix/flaky-hie-bios-test
Fix flaky hie bios test
2 parents a734e1a + d1a1471 commit 552be36

File tree

5 files changed

+15
-29
lines changed

5 files changed

+15
-29
lines changed

test/functional/HieBios.hs

+8-25
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,15 @@ 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
26-
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"
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"
19+
]

test/testdata/hieBiosError/Foo.hs

-1
This file was deleted.

test/testdata/hieBiosMainIs/Main.hs

+4-2
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .

test/testdata/hieBiosMainIs/hieBiosMainIs.cabal

+2-1
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)