Skip to content

Commit 9593d04

Browse files
authored
move ghcide-tests to haskell-language-server.cabal and make it depend on hls-test-utils (#4176)
* move ghcide-tests to haskell-language-server.cabal and make it depend on hls-test-utils * migrate initializeResponseTests * cleanup
1 parent e6f7be7 commit 9593d04

File tree

4 files changed

+120
-107
lines changed

4 files changed

+120
-107
lines changed

ghcide/ghcide.cabal

-98
Original file line numberDiff line numberDiff line change
@@ -297,101 +297,3 @@ library ghcide-test-utils
297297
OverloadedStrings
298298
RecordWildCards
299299
ViewPatterns
300-
301-
test-suite ghcide-tests
302-
import: warnings
303-
type: exitcode-stdio-1.0
304-
default-language: GHC2021
305-
build-tool-depends:
306-
, ghcide:ghcide
307-
, ghcide:ghcide-test-preprocessor
308-
, implicit-hie:gen-hie
309-
310-
build-depends:
311-
, aeson
312-
, async
313-
, base
314-
, containers
315-
, data-default
316-
, directory
317-
, enummapset
318-
, extra
319-
, filepath
320-
, fuzzy
321-
, ghcide
322-
, ghcide:ghcide-test-utils
323-
, hls-plugin-api
324-
, lens
325-
, list-t
326-
, lsp
327-
, lsp-test ^>=0.17.0.0
328-
, lsp-types
329-
, monoid-subclasses
330-
, mtl
331-
, network-uri
332-
, QuickCheck
333-
, random
334-
, regex-tdfa ^>=1.3.1
335-
, row-types
336-
, shake
337-
, sqlite-simple
338-
, stm
339-
, stm-containers
340-
, tasty
341-
, tasty-expected-failure
342-
, tasty-hunit >=0.10
343-
, tasty-quickcheck
344-
, tasty-rerun
345-
, text
346-
, text-rope
347-
, unordered-containers
348-
349-
if impl(ghc <9.3)
350-
build-depends: ghc-typelits-knownnat
351-
352-
hs-source-dirs: test/exe
353-
ghc-options: -threaded -O0
354-
355-
main-is: Main.hs
356-
other-modules:
357-
AsyncTests
358-
BootTests
359-
ClientSettingsTests
360-
CodeLensTests
361-
CompletionTests
362-
CPPTests
363-
CradleTests
364-
DependentFileTest
365-
DiagnosticTests
366-
ExceptionTests
367-
FindDefinitionAndHoverTests
368-
FuzzySearch
369-
GarbageCollectionTests
370-
HaddockTests
371-
HieDbRetry
372-
HighlightTests
373-
IfaceTests
374-
InitializeResponseTests
375-
LogType
376-
NonLspCommandLine
377-
OpenCloseTest
378-
OutlineTests
379-
PluginSimpleTests
380-
PositionMappingTests
381-
PreprocessorTests
382-
Progress
383-
ReferenceTests
384-
RootUriTests
385-
SafeTests
386-
SymlinkTests
387-
TestUtils
388-
THTests
389-
UnitTests
390-
WatchedFileTests
391-
392-
-- Tests that have been pulled out of the main file
393-
default-extensions:
394-
LambdaCase
395-
OverloadedStrings
396-
RecordWildCards
397-
ViewPatterns

ghcide/test/exe/Config.hs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Config where
2+
import Ide.Types (defaultPluginDescriptor)
3+
import System.FilePath ((</>))
4+
import Test.Hls (PluginTestDescriptor,
5+
mkPluginTestDescriptor)
6+
import qualified Test.Hls.FileSystem as FS
7+
8+
testDataDir :: FilePath
9+
testDataDir = "ghcide" </> "test" </> "data"
10+
11+
mkIdeTestFs :: [FS.FileTree] -> FS.VirtualFileTree
12+
mkIdeTestFs = FS.mkVirtualFileTree testDataDir
13+
14+
-- * A dummy plugin for testing ghcIde
15+
dummyPlugin :: PluginTestDescriptor ()
16+
dummyPlugin = mkPluginTestDescriptor (\_ pid ->defaultPluginDescriptor pid "dummyTestPlugin") "core"

ghcide/test/exe/InitializeResponseTests.hs

+3-9
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@ import qualified Data.Text as T
1111
import Development.IDE.Plugin.TypeLenses (typeLensCommandId)
1212
import qualified Language.LSP.Protocol.Lens as L
1313
import Language.LSP.Protocol.Message
14-
import Language.LSP.Protocol.Types hiding
15-
(SemanticTokenAbsolute (..),
16-
SemanticTokenRelative (..),
17-
SemanticTokensEdit (..),
18-
mkRange)
1914
import Language.LSP.Test
2015

16+
import Config (dummyPlugin, mkIdeTestFs)
2117
import Control.Lens ((^.))
2218
import Development.IDE.Plugin.Test (blockCommandId)
23-
import Test.Tasty
24-
import Test.Tasty.HUnit
25-
import TestUtils
19+
import Test.Hls
2620

2721
tests :: TestTree
2822
tests = withResource acquire release tests where
@@ -90,7 +84,7 @@ tests = withResource acquire release tests where
9084
innerCaps (TResponseMessage _ _ (Left _)) = error "Initialization error"
9185

9286
acquire :: IO (TResponseMessage Method_Initialize)
93-
acquire = run initializeResponse
87+
acquire = runSessionWithServerInTmpDir def dummyPlugin (mkIdeTestFs []) initializeResponse
9488

9589
release :: TResponseMessage Method_Initialize -> IO ()
9690
release = mempty

haskell-language-server.cabal

+101
Original file line numberDiff line numberDiff line change
@@ -2097,3 +2097,104 @@ benchmark benchmark
20972097
, shake-bench == 0.2.*
20982098
, text
20992099
, yaml
2100+
2101+
2102+
test-suite ghcide-tests
2103+
import: warnings
2104+
type: exitcode-stdio-1.0
2105+
default-language: GHC2021
2106+
build-tool-depends:
2107+
, ghcide:ghcide
2108+
, ghcide:ghcide-test-preprocessor
2109+
, implicit-hie:gen-hie
2110+
2111+
build-depends:
2112+
, aeson
2113+
, async
2114+
, base
2115+
, containers
2116+
, data-default
2117+
, directory
2118+
, enummapset
2119+
, extra
2120+
, filepath
2121+
, fuzzy
2122+
, ghcide
2123+
, ghcide:ghcide-test-utils
2124+
, hls-plugin-api
2125+
, lens
2126+
, list-t
2127+
, lsp
2128+
, lsp-test ^>=0.17.0.0
2129+
, lsp-types
2130+
, monoid-subclasses
2131+
, mtl
2132+
, network-uri
2133+
, QuickCheck
2134+
, random
2135+
, regex-tdfa ^>=1.3.1
2136+
, row-types
2137+
, shake
2138+
, sqlite-simple
2139+
, stm
2140+
, stm-containers
2141+
, tasty
2142+
, tasty-expected-failure
2143+
, tasty-hunit >=0.10
2144+
, tasty-quickcheck
2145+
, tasty-rerun
2146+
, text
2147+
, text-rope
2148+
, unordered-containers
2149+
, hls-test-utils == 2.7.0.0
2150+
2151+
if impl(ghc <9.3)
2152+
build-depends: ghc-typelits-knownnat
2153+
2154+
hs-source-dirs: ghcide/test/exe
2155+
ghc-options: -threaded -O0
2156+
2157+
main-is: Main.hs
2158+
other-modules:
2159+
Config
2160+
AsyncTests
2161+
BootTests
2162+
ClientSettingsTests
2163+
CodeLensTests
2164+
CompletionTests
2165+
CPPTests
2166+
CradleTests
2167+
DependentFileTest
2168+
DiagnosticTests
2169+
ExceptionTests
2170+
FindDefinitionAndHoverTests
2171+
FuzzySearch
2172+
GarbageCollectionTests
2173+
HaddockTests
2174+
HieDbRetry
2175+
HighlightTests
2176+
IfaceTests
2177+
InitializeResponseTests
2178+
LogType
2179+
NonLspCommandLine
2180+
OpenCloseTest
2181+
OutlineTests
2182+
PluginSimpleTests
2183+
PositionMappingTests
2184+
PreprocessorTests
2185+
Progress
2186+
ReferenceTests
2187+
RootUriTests
2188+
SafeTests
2189+
SymlinkTests
2190+
TestUtils
2191+
THTests
2192+
UnitTests
2193+
WatchedFileTests
2194+
2195+
-- Tests that have been pulled out of the main file
2196+
default-extensions:
2197+
LambdaCase
2198+
OverloadedStrings
2199+
RecordWildCards
2200+
ViewPatterns

0 commit comments

Comments
 (0)