From 2d506c492ddb5861d4af86de734f6a08aa3fcda0 Mon Sep 17 00:00:00 2001 From: Fendor Date: Wed, 20 Sep 2023 13:38:40 +0200 Subject: [PATCH 1/2] Fix hie-bios functional tests --- test/functional/HieBios.hs | 38 +++++++------------ test/testdata/hieBiosMainIs/Main.hs | 6 ++- test/testdata/hieBiosMainIs/cabal.project | 1 + .../hieBiosMainIs/hieBiosMainIs.cabal | 3 +- 4 files changed, 21 insertions(+), 27 deletions(-) create mode 100644 test/testdata/hieBiosMainIs/cabal.project diff --git a/test/functional/HieBios.hs b/test/functional/HieBios.hs index 28e76aa4ff..dddc1a8de9 100644 --- a/test/functional/HieBios.hs +++ b/test/functional/HieBios.hs @@ -5,32 +5,22 @@ 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 +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" - , 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" + , expectFailBecause "hie-bios 0.11 has poor error messages" $ testCase "reports errors in hie.yaml" $ do + runSession hlsCommand fullCaps "test/testdata/hieBiosError" $ do + _ <- openDoc "Foo.hs" "haskell" + (diag:_) <- waitForDiagnostics + liftIO $ "Expected a cradle: key containing the preferences" `T.isInfixOf` (diag ^. L.message) + @? "Expected missing top-level binding diagnostic" + ] diff --git a/test/testdata/hieBiosMainIs/Main.hs b/test/testdata/hieBiosMainIs/Main.hs index 65ae4a05d5..c3c579788f 100644 --- a/test/testdata/hieBiosMainIs/Main.hs +++ b/test/testdata/hieBiosMainIs/Main.hs @@ -1,4 +1,6 @@ -module Main where +module Main (main) where main :: IO () -main = putStrLn "Hello, Haskell!" +main = print foo + +foo = 5 :: Int diff --git a/test/testdata/hieBiosMainIs/cabal.project b/test/testdata/hieBiosMainIs/cabal.project new file mode 100644 index 0000000000..e6fdbadb43 --- /dev/null +++ b/test/testdata/hieBiosMainIs/cabal.project @@ -0,0 +1 @@ +packages: . diff --git a/test/testdata/hieBiosMainIs/hieBiosMainIs.cabal b/test/testdata/hieBiosMainIs/hieBiosMainIs.cabal index d7efa971e0..87c5dc421a 100644 --- a/test/testdata/hieBiosMainIs/hieBiosMainIs.cabal +++ b/test/testdata/hieBiosMainIs/hieBiosMainIs.cabal @@ -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 From 801e365e3bae3aac6bbcbe52aca15ebcc29791eb Mon Sep 17 00:00:00 2001 From: Fendor Date: Wed, 20 Sep 2023 13:41:55 +0200 Subject: [PATCH 2/2] Remove ignored hie-bios integration test --- test/functional/HieBios.hs | 7 ------- test/testdata/hieBiosError/Foo.hs | 1 - 2 files changed, 8 deletions(-) delete mode 100644 test/testdata/hieBiosError/Foo.hs diff --git a/test/functional/HieBios.hs b/test/functional/HieBios.hs index dddc1a8de9..0e6fe562f2 100644 --- a/test/functional/HieBios.hs +++ b/test/functional/HieBios.hs @@ -16,11 +16,4 @@ tests = testGroup "hie-bios" (diag:_) <- waitForDiagnostics liftIO $ "Top-level binding with no type signature:" `T.isInfixOf` (diag ^. L.message) @? "Expected missing top-level binding diagnostic" - - , expectFailBecause "hie-bios 0.11 has poor error messages" $ testCase "reports errors in hie.yaml" $ do - runSession hlsCommand fullCaps "test/testdata/hieBiosError" $ do - _ <- openDoc "Foo.hs" "haskell" - (diag:_) <- waitForDiagnostics - liftIO $ "Expected a cradle: key containing the preferences" `T.isInfixOf` (diag ^. L.message) - @? "Expected missing top-level binding diagnostic" ] diff --git a/test/testdata/hieBiosError/Foo.hs b/test/testdata/hieBiosError/Foo.hs deleted file mode 100644 index e495355ec9..0000000000 --- a/test/testdata/hieBiosError/Foo.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStrLn "hey"