Skip to content

Commit fffc04d

Browse files
authored
Move hlint tests to its own package (and other clean ups) (#2284)
* Move hlint tests to its package * Move hlint config tests to its package * Update extra-source-files * Remove unused cabal-helper test data * Add hlint test suite * Make diganostic tests work without hlint * Make progressCap test work without hlint files * No cabal files in hlint test data * Fix progress test * Fix parent folder name * Correct test data dir * Correct extra-source dir and update maintainer * Use sendConfigurationChanged everywhere
1 parent f3cdf09 commit fffc04d

Some content is hidden

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

69 files changed

+359
-554
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,7 @@ jobs:
215215
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test}}
216216
name: Test hls-rename-plugin test suite
217217
run: cabal test hls-rename-plugin --test-options="-j1 --rerun-update" || cabal test hls-rename-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-rename-plugin --test-options="-j1 --rerun"
218+
219+
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test}}
220+
name: Test hls-hlint-plugin test suite
221+
run: cabal test hls-hlint-plugin --test-options="-j1 --rerun-update" || cabal test hls-hlint-plugin --test-options="-j1 --rerun" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-hlint-plugin --test-options="-j1 --rerun"

haskell-language-server.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ extra-source-files:
2121
test/testdata/**/*.project
2222
test/testdata/**/*.cabal
2323
test/testdata/**/*.yaml
24-
-- this one is not matched by the previous glob
25-
test/testdata/hlint/ignore/.hlint.yaml
26-
test/testdata/**/*.h
2724
test/testdata/**/*.hs
2825

2926
flag pedantic

hls-test-utils/src/Test/Hls.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ module Test.Hls
2424
waitForAllProgressDone,
2525
PluginDescriptor,
2626
IdeState,
27-
waitForBuildQueue
28-
,waitForTypecheck,waitForAction)
27+
waitForBuildQueue,
28+
waitForTypecheck,
29+
waitForAction,
30+
sendConfigurationChanged)
2931
where
3032

3133
import Control.Applicative.Combinators
@@ -222,8 +224,12 @@ waitForAction key TextDocumentIdentifier{_uri} = do
222224
return $ do
223225
e <- _result
224226
case A.fromJSON e of
225-
A.Error e -> Left $ ResponseError InternalError (T.pack e) Nothing
227+
A.Error err -> Left $ ResponseError InternalError (T.pack err) Nothing
226228
A.Success a -> pure a
227229

228230
waitForTypecheck :: TextDocumentIdentifier -> Session (Either ResponseError Bool)
229231
waitForTypecheck tid = fmap ideResultSuccess <$> waitForAction "typecheck" tid
232+
233+
sendConfigurationChanged :: Value -> Session ()
234+
sendConfigurationChanged config =
235+
sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams config)

hls-test-utils/src/Test/Hls/Util.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module Test.Hls.Util
2222
, ghcVersion, GhcVersion(..)
2323
, hostOS, OS(..)
2424
, matchesCurrentEnv, EnvSpec(..)
25+
, noLiteralCaps
2526
, ignoreForGhcVersions
2627
, ignoreInEnv
2728
, inspectCodeAction
@@ -74,6 +75,12 @@ import Test.Tasty.HUnit (Assertion, assertFailure,
7475
import Text.Blaze.Internal hiding (null)
7576
import Text.Blaze.Renderer.String (renderMarkup)
7677

78+
noLiteralCaps :: C.ClientCapabilities
79+
noLiteralCaps = def { C._textDocument = Just textDocumentCaps }
80+
where
81+
textDocumentCaps = def { C._codeAction = Just codeActionCaps }
82+
codeActionCaps = CodeActionClientCapabilities (Just True) Nothing Nothing Nothing Nothing Nothing Nothing
83+
7784
codeActionSupportCaps :: C.ClientCapabilities
7885
codeActionSupportCaps = def { C._textDocument = Just textDocumentCaps }
7986
where

plugins/hls-hlint-plugin/hls-hlint-plugin.cabal

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cabal-version: 2.2
1+
cabal-version: 2.4
22
name: hls-hlint-plugin
33
version: 1.0.1.1
44
synopsis: Hlint integration plugin with Haskell Language Server
@@ -8,10 +8,17 @@ description:
88
license: Apache-2.0
99
license-file: LICENSE
1010
author: The Haskell IDE Team
11-
maintainer: alan.zimm@gmail.com
11+
maintainer: atreyu.bbb@gmail.com
1212
copyright: The Haskell IDE Team
1313
category: Development
1414
build-type: Simple
15+
extra-source-files:
16+
LICENSE
17+
test/testdata/**/*.yaml
18+
-- this one is not matched by the previous glob
19+
test/testdata/ignore/.hlint.yaml
20+
test/testdata/**/*.hs
21+
test/testdata/**/*.h
1522

1623
flag pedantic
1724
description: Enable -Werror
@@ -101,3 +108,21 @@ library
101108
default-extensions:
102109
DataKinds
103110
TypeOperators
111+
112+
test-suite tests
113+
type: exitcode-stdio-1.0
114+
default-language: Haskell2010
115+
hs-source-dirs: test
116+
main-is: Main.hs
117+
ghc-options: -threaded -rtsopts -with-rtsopts=-N
118+
build-depends:
119+
aeson
120+
, base
121+
, containers
122+
, filepath
123+
, hls-hlint-plugin
124+
, hls-plugin-api
125+
, hls-test-utils >=1.0 && <1.2
126+
, lens
127+
, lsp-types
128+
, text

0 commit comments

Comments
 (0)