Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky hie bios test #3814

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions test/functional/HieBios.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,15 @@ import Control.Lens ((^.))
import Control.Monad.IO.Class
import qualified Data.Text as T
import qualified Language.LSP.Protocol.Lens as L
import System.FilePath ((</>))
import Test.Hls
import Test.Hls.Command


tests :: TestTree
tests = testGroup "hie-bios" [
testCase "loads modules inside main-is" $ do
writeFile (hieBiosErrorPath </> "hie.yaml") ""
runSession hlsCommand fullCaps "test/testdata/hieBiosMainIs" $ do
doc <- openDoc "Main.hs" "haskell"
Just mainHoverText <- getHover doc (Position 3 1)
let hoverContents = mainHoverText ^. L.contents
case hoverContents of
(InL (MarkupContent _ x)) -> do
liftIO $ "main :: IO ()" `T.isInfixOf` x
@? "found hover text for main"
_ -> error $ "Unexpected hover contents: " ++ show hoverContents

, expectFailBecause "hie-bios 0.11 has poor error messages" $ testCase "reports errors in hie.yaml" $ do
writeFile (hieBiosErrorPath </> "hie.yaml") ""
runSession hlsCommand fullCaps hieBiosErrorPath $ do
_ <- openDoc "Foo.hs" "haskell"
(diag:_) <- waitForDiagnostics
liftIO $ "Expected a cradle: key containing the preferences" `T.isInfixOf` (diag ^. L.message)
@? "Error reported"
]
where
hieBiosErrorPath = "test/testdata/hieBiosError"
tests = testGroup "hie-bios"
[ testCase "loads main-is module" $ do
runSession hlsCommand fullCaps "test/testdata/hieBiosMainIs" $ do
_ <- openDoc "Main.hs" "haskell"
(diag:_) <- waitForDiagnostics
liftIO $ "Top-level binding with no type signature:" `T.isInfixOf` (diag ^. L.message)
@? "Expected missing top-level binding diagnostic"
]
1 change: 0 additions & 1 deletion test/testdata/hieBiosError/Foo.hs

This file was deleted.

6 changes: 4 additions & 2 deletions test/testdata/hieBiosMainIs/Main.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module Main where
module Main (main) where

main :: IO ()
main = putStrLn "Hello, Haskell!"
main = print foo

foo = 5 :: Int
1 change: 1 addition & 0 deletions test/testdata/hieBiosMainIs/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
3 changes: 2 additions & 1 deletion test/testdata/hieBiosMainIs/hieBiosMainIs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ version: 0.1.0.0
build-type: Simple
executable hieBiosMainIs
main-is: Main.hs
build-depends: base >=4.12 && <4.13
build-depends: base
default-language: Haskell2010
ghc-options: -Wall
Loading