From c33b34a7d6ad91d47deee5689dcd2ccb9a67ac02 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 14 Apr 2024 20:13:51 +0800 Subject: [PATCH 1/3] move ghcide-tests to haskell-language-server.cabal and make it depend on hls-test-utils --- ghcide/ghcide.cabal | 98 --------------------------------- haskell-language-server.cabal | 100 ++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/ghcide/ghcide.cabal b/ghcide/ghcide.cabal index 16aeaa06de..2e314cce04 100644 --- a/ghcide/ghcide.cabal +++ b/ghcide/ghcide.cabal @@ -297,101 +297,3 @@ library ghcide-test-utils OverloadedStrings RecordWildCards ViewPatterns - -test-suite ghcide-tests - import: warnings - type: exitcode-stdio-1.0 - default-language: GHC2021 - build-tool-depends: - , ghcide:ghcide - , ghcide:ghcide-test-preprocessor - , implicit-hie:gen-hie - - build-depends: - , aeson - , async - , base - , containers - , data-default - , directory - , enummapset - , extra - , filepath - , fuzzy - , ghcide - , ghcide:ghcide-test-utils - , hls-plugin-api - , lens - , list-t - , lsp - , lsp-test ^>=0.17.0.0 - , lsp-types - , monoid-subclasses - , mtl - , network-uri - , QuickCheck - , random - , regex-tdfa ^>=1.3.1 - , row-types - , shake - , sqlite-simple - , stm - , stm-containers - , tasty - , tasty-expected-failure - , tasty-hunit >=0.10 - , tasty-quickcheck - , tasty-rerun - , text - , text-rope - , unordered-containers - - if impl(ghc <9.3) - build-depends: ghc-typelits-knownnat - - hs-source-dirs: test/exe - ghc-options: -threaded -O0 - - main-is: Main.hs - other-modules: - AsyncTests - BootTests - ClientSettingsTests - CodeLensTests - CompletionTests - CPPTests - CradleTests - DependentFileTest - DiagnosticTests - ExceptionTests - FindDefinitionAndHoverTests - FuzzySearch - GarbageCollectionTests - HaddockTests - HieDbRetry - HighlightTests - IfaceTests - InitializeResponseTests - LogType - NonLspCommandLine - OpenCloseTest - OutlineTests - PluginSimpleTests - PositionMappingTests - PreprocessorTests - Progress - ReferenceTests - RootUriTests - SafeTests - SymlinkTests - TestUtils - THTests - UnitTests - WatchedFileTests - - -- Tests that have been pulled out of the main file - default-extensions: - LambdaCase - OverloadedStrings - RecordWildCards - ViewPatterns diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index ad3b6ea097..c10d072f3f 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -2097,3 +2097,103 @@ benchmark benchmark , shake-bench == 0.2.* , text , yaml + + +test-suite ghcide-tests + import: warnings + type: exitcode-stdio-1.0 + default-language: GHC2021 + build-tool-depends: + , ghcide:ghcide + , ghcide:ghcide-test-preprocessor + , implicit-hie:gen-hie + + build-depends: + , aeson + , async + , base + , containers + , data-default + , directory + , enummapset + , extra + , filepath + , fuzzy + , ghcide + , ghcide:ghcide-test-utils + , hls-plugin-api + , lens + , list-t + , lsp + , lsp-test ^>=0.17.0.0 + , lsp-types + , monoid-subclasses + , mtl + , network-uri + , QuickCheck + , random + , regex-tdfa ^>=1.3.1 + , row-types + , shake + , sqlite-simple + , stm + , stm-containers + , tasty + , tasty-expected-failure + , tasty-hunit >=0.10 + , tasty-quickcheck + , tasty-rerun + , text + , text-rope + , unordered-containers + , hls-test-utils == 2.7.0.0 + + if impl(ghc <9.3) + build-depends: ghc-typelits-knownnat + + hs-source-dirs: ghcide/test/exe + ghc-options: -threaded -O0 + + main-is: Main.hs + other-modules: + AsyncTests + BootTests + ClientSettingsTests + CodeLensTests + CompletionTests + CPPTests + CradleTests + DependentFileTest + DiagnosticTests + ExceptionTests + FindDefinitionAndHoverTests + FuzzySearch + GarbageCollectionTests + HaddockTests + HieDbRetry + HighlightTests + IfaceTests + InitializeResponseTests + LogType + NonLspCommandLine + OpenCloseTest + OutlineTests + PluginSimpleTests + PositionMappingTests + PreprocessorTests + Progress + ReferenceTests + RootUriTests + SafeTests + SymlinkTests + TestUtils + THTests + UnitTests + WatchedFileTests + + -- Tests that have been pulled out of the main file + default-extensions: + LambdaCase + OverloadedStrings + RecordWildCards + ViewPatterns From b5466bf6cb1095e02dfd9834887945e72a470c28 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 16 Apr 2024 23:48:13 +0800 Subject: [PATCH 2/3] migrate initializeResponseTests --- ghcide/test/exe/Config.hs | 16 ++++++++++++++++ ghcide/test/exe/InitializeResponseTests.hs | 18 +++++++----------- haskell-language-server.cabal | 1 + 3 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 ghcide/test/exe/Config.hs diff --git a/ghcide/test/exe/Config.hs b/ghcide/test/exe/Config.hs new file mode 100644 index 0000000000..565e6c9ceb --- /dev/null +++ b/ghcide/test/exe/Config.hs @@ -0,0 +1,16 @@ +module Config where +import Ide.Types (defaultPluginDescriptor) +import System.FilePath (()) +import Test.Hls (PluginTestDescriptor, + mkPluginTestDescriptor) +import qualified Test.Hls.FileSystem as FS + +testDataDir :: FilePath +testDataDir = "ghcide" "test" "data" + +mkIdeTestFs :: [FS.FileTree] -> FS.VirtualFileTree +mkIdeTestFs = FS.mkVirtualFileTree testDataDir + +-- * A dummy plugin for testing ghcIde +dummyPlugin :: PluginTestDescriptor () +dummyPlugin = mkPluginTestDescriptor (\_ pid ->defaultPluginDescriptor pid "dummyTestPlugin") "core" diff --git a/ghcide/test/exe/InitializeResponseTests.hs b/ghcide/test/exe/InitializeResponseTests.hs index a980efc12d..8ae723e0d3 100644 --- a/ghcide/test/exe/InitializeResponseTests.hs +++ b/ghcide/test/exe/InitializeResponseTests.hs @@ -1,6 +1,8 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE ExplicitNamespaces #-} +{-# LANGUAGE OverloadedLabels #-} +{-# LANGUAGE OverloadedStrings #-} module InitializeResponseTests (tests) where @@ -11,18 +13,12 @@ import qualified Data.Text as T import Development.IDE.Plugin.TypeLenses (typeLensCommandId) import qualified Language.LSP.Protocol.Lens as L import Language.LSP.Protocol.Message -import Language.LSP.Protocol.Types hiding - (SemanticTokenAbsolute (..), - SemanticTokenRelative (..), - SemanticTokensEdit (..), - mkRange) import Language.LSP.Test +import Config (dummyPlugin, mkIdeTestFs) import Control.Lens ((^.)) import Development.IDE.Plugin.Test (blockCommandId) -import Test.Tasty -import Test.Tasty.HUnit -import TestUtils +import Test.Hls tests :: TestTree tests = withResource acquire release tests where @@ -90,7 +86,7 @@ tests = withResource acquire release tests where innerCaps (TResponseMessage _ _ (Left _)) = error "Initialization error" acquire :: IO (TResponseMessage Method_Initialize) - acquire = run initializeResponse + acquire = runSessionWithServerInTmpDir def dummyPlugin (mkIdeTestFs []) initializeResponse release :: TResponseMessage Method_Initialize -> IO () release = mempty diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index c10d072f3f..759288f081 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -2156,6 +2156,7 @@ test-suite ghcide-tests main-is: Main.hs other-modules: + Config AsyncTests BootTests ClientSettingsTests From 3fe078ad49f6df0c55235d3ce598f21811a94eef Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 16 Apr 2024 23:50:02 +0800 Subject: [PATCH 3/3] cleanup --- ghcide/test/exe/InitializeResponseTests.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ghcide/test/exe/InitializeResponseTests.hs b/ghcide/test/exe/InitializeResponseTests.hs index 8ae723e0d3..ab34bdfd54 100644 --- a/ghcide/test/exe/InitializeResponseTests.hs +++ b/ghcide/test/exe/InitializeResponseTests.hs @@ -1,8 +1,6 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE ExplicitNamespaces #-} -{-# LANGUAGE OverloadedLabels #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE OverloadedLabels #-} module InitializeResponseTests (tests) where