Skip to content

Commit 34d4793

Browse files
authored
Merge pull request #105 from jeffwindsor/issue-5
Issue 5 - Move HIE Tests and convert to Tasty
2 parents 144457f + 0c1708f commit 34d4793

File tree

146 files changed

+3345
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+3345
-593
lines changed

haskell-language-server.cabal

Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -205,69 +205,59 @@ executable haskell-language-server-wrapper
205205
, process
206206
default-language: Haskell2010
207207

208-
209208
test-suite func-test
210-
import: agpl
211-
type: exitcode-stdio-1.0
212-
default-language: Haskell2010
213-
build-tool-depends: hspec-discover:hspec-discover
214-
, haskell-language-server:haskell-language-server
215-
, cabal-helper:cabal-helper-main
216-
, ghcide:ghcide-test-preprocessor
217-
218-
build-depends:
219-
base >=4.7 && <5
220-
, aeson
221-
, data-default
222-
, haskell-lsp-types == 0.22.*
223-
, hls-test-utils
224-
, hspec
225-
, lens
226-
, lsp-test >= 0.10.0.0
227-
, text
228-
, unordered-containers
229-
other-modules:
230-
-- CompletionSpec
231-
-- , CommandSpec
232-
-- , DeferredSpec
233-
-- , DefinitionSpec
234-
-- , DiagnosticsSpec
235-
FormatSpec
236-
-- , FunctionalBadProjectSpec
237-
-- , FunctionalCodeActionsSpec
238-
-- , FunctionalLiquidSpec
239-
, FunctionalSpec
240-
-- , HaReSpec
241-
-- , HieBiosSpec
242-
-- , HighlightSpec
243-
-- , HoverSpec
244-
, PluginSpec
245-
-- , ProgressSpec
246-
-- , ReferencesSpec
247-
-- , RenameSpec
248-
-- , SymbolsSpec
249-
-- , TypeDefinitionSpec
250-
, Utils
251-
, Paths_haskell_language_server
252-
253-
hs-source-dirs:
254-
test/functional
255-
ghc-options:
256-
-Wall
257-
-Wredundant-constraints
258-
-Wno-name-shadowing
259-
-threaded -rtsopts -with-rtsopts=-N
209+
import: agpl
210+
type: exitcode-stdio-1.0
211+
default-language: Haskell2010
212+
build-tool-depends: haskell-language-server:haskell-language-server
213+
, ghcide:ghcide-test-preprocessor
214+
build-depends: base >=4.7 && <5
215+
, aeson
216+
, data-default
217+
, directory
218+
, filepath
219+
, haskell-language-server
220+
, haskell-lsp
221+
, haskell-lsp-types
222+
, hls-test-utils
223+
, hspec-expectations
224+
, lens
225+
, lsp-test >= 0.10.0.0
226+
, tasty
227+
, tasty-ant-xml
228+
, tasty-expected-failure
229+
, tasty-hunit
230+
, tasty-rerun
231+
, text
232+
, unordered-containers
233+
hs-source-dirs: test/functional
234+
main-is: Main.hs
235+
other-modules: Command
236+
, Completion
237+
, Deferred
238+
, Definition
239+
, Diagnostic
240+
, Format
241+
, FunctionalBadProject
242+
, FunctionalCodeAction
243+
, FunctionalLiquid
244+
, HieBios
245+
, Highlight
246+
, Progress
247+
, Reference
248+
, Rename
249+
, Symbol
250+
, TypeDefinition
251+
ghc-options: -Wall
252+
-Wno-name-shadowing
253+
-threaded -rtsopts -with-rtsopts=-N
260254
if flag(pedantic)
261-
ghc-options: -Werror
262-
main-is: Main.hs
263-
-- other-modules:
264-
-- Development.IDE.Test
265-
-- Development.IDE.Test.Runfiles
255+
ghc-options: -Werror -Wredundant-constraints
266256

267257
library hls-test-utils
268258
import: agpl
269259
hs-source-dirs: test/utils
270-
exposed-modules: TestUtils
260+
exposed-modules: Test.Hls.Util
271261
build-depends: base
272262
, haskell-language-server
273263
, haskell-lsp
@@ -281,7 +271,9 @@ library hls-test-utils
281271
, hslogger
282272
, hspec
283273
, hspec-core
274+
, lsp-test
284275
, stm
276+
, tasty-hunit
285277
, text
286278
, unordered-containers
287279
, yaml

hie.yaml.stack

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ cradle:
66
- path: "./test/functional/"
77
component: "haskell-language-server:func-test"
88

9+
- path: "./test/src/"
10+
component: "haskell-language-server:tasty"
11+
912
# This target does not currently work (stack 2.1.3)
1013
# - path: "./test/utils"
1114
# component: "haskell-language-server:lib:hls-test-utils"

test/functional/Command.hs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
module Command (tests) where
3+
4+
import Control.Lens hiding (List)
5+
import Control.Monad.IO.Class
6+
import qualified Data.Text as T
7+
import Data.Char
8+
import Language.Haskell.LSP.Test
9+
import Language.Haskell.LSP.Types as LSP
10+
import Language.Haskell.LSP.Types.Lens as LSP
11+
import Test.Hls.Util
12+
import Test.Tasty
13+
import Test.Tasty.HUnit
14+
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
15+
import Test.Hspec.Expectations
16+
17+
18+
--TODO : Response Message no longer has 4 inputs
19+
tests :: TestTree
20+
tests = testGroup "commands" [
21+
testCase "are prefixed" $
22+
runSession hieCommand fullCaps "test/testdata/" $ do
23+
ResponseMessage _ _ (Right res) <- initializeResponse
24+
let List cmds = res ^. LSP.capabilities . executeCommandProvider . _Just . commands
25+
f x = (T.length (T.takeWhile isNumber x) >= 1) && (T.count ":" x >= 2)
26+
liftIO $ do
27+
cmds `shouldSatisfy` all f
28+
cmds `shouldNotSatisfy` null
29+
, ignoreTestBecause "Broken: Plugin package doesn't exist" $
30+
testCase "get de-prefixed" $
31+
runSession hieCommand fullCaps "test/testdata/" $ do
32+
ResponseMessage _ _ (Left err) <- request
33+
WorkspaceExecuteCommand
34+
(ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse
35+
let ResponseError _ msg _ = err
36+
-- We expect an error message about the dud arguments, but should pickup "add" and "package"
37+
liftIO $ msg `shouldSatisfy` T.isInfixOf "while parsing args for add in plugin package"
38+
]

0 commit comments

Comments
 (0)