Skip to content

Commit

Permalink
move ghcide-tests to haskell-language-server.cabal and make it depend…
Browse files Browse the repository at this point in the history
… on hls-test-utils (haskell#4176)

* move ghcide-tests to haskell-language-server.cabal and make it depend on hls-test-utils

* migrate initializeResponseTests

* cleanup
  • Loading branch information
soulomoon authored Apr 17, 2024
1 parent e6f7be7 commit 9593d04
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 107 deletions.
98 changes: 0 additions & 98 deletions ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions ghcide/test/exe/Config.hs
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 3 additions & 9 deletions ghcide/test/exe/InitializeResponseTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,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
Expand Down Expand Up @@ -90,7 +84,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
Expand Down
101 changes: 101 additions & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2097,3 +2097,104 @@ 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:
Config
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

0 comments on commit 9593d04

Please sign in to comment.