Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move hlint tests to its own package (and other clean ups) #2284

Merged
merged 15 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,7 @@ jobs:
- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test}}
name: Test hls-rename-plugin test suite
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"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' && matrix.test}}
name: Test hls-hlint-plugin test suite
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"
3 changes: 0 additions & 3 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ extra-source-files:
test/testdata/**/*.project
test/testdata/**/*.cabal
test/testdata/**/*.yaml
-- this one is not matched by the previous glob
test/testdata/hlint/ignore/.hlint.yaml
test/testdata/**/*.h
test/testdata/**/*.hs

flag pedantic
Expand Down
12 changes: 9 additions & 3 deletions hls-test-utils/src/Test/Hls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ module Test.Hls
waitForAllProgressDone,
PluginDescriptor,
IdeState,
waitForBuildQueue
,waitForTypecheck,waitForAction)
waitForBuildQueue,
waitForTypecheck,
waitForAction,
sendConfigurationChanged)
where

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

waitForTypecheck :: TextDocumentIdentifier -> Session (Either ResponseError Bool)
waitForTypecheck tid = fmap ideResultSuccess <$> waitForAction "typecheck" tid

sendConfigurationChanged :: Value -> Session ()
sendConfigurationChanged config =
sendNotification SWorkspaceDidChangeConfiguration (DidChangeConfigurationParams config)
7 changes: 7 additions & 0 deletions hls-test-utils/src/Test/Hls/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Test.Hls.Util
, ghcVersion, GhcVersion(..)
, hostOS, OS(..)
, matchesCurrentEnv, EnvSpec(..)
, noLiteralCaps
, ignoreForGhcVersions
, ignoreInEnv
, inspectCodeAction
Expand Down Expand Up @@ -74,6 +75,12 @@ import Test.Tasty.HUnit (Assertion, assertFailure,
import Text.Blaze.Internal hiding (null)
import Text.Blaze.Renderer.String (renderMarkup)

noLiteralCaps :: C.ClientCapabilities
noLiteralCaps = def { C._textDocument = Just textDocumentCaps }
where
textDocumentCaps = def { C._codeAction = Just codeActionCaps }
codeActionCaps = CodeActionClientCapabilities (Just True) Nothing Nothing Nothing Nothing Nothing Nothing

codeActionSupportCaps :: C.ClientCapabilities
codeActionSupportCaps = def { C._textDocument = Just textDocumentCaps }
where
Expand Down
29 changes: 27 additions & 2 deletions plugins/hls-hlint-plugin/hls-hlint-plugin.cabal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cabal-version: 2.2
cabal-version: 2.4
name: hls-hlint-plugin
version: 1.0.1.1
synopsis: Hlint integration plugin with Haskell Language Server
Expand All @@ -8,10 +8,17 @@ description:
license: Apache-2.0
license-file: LICENSE
author: The Haskell IDE Team
maintainer: alan.zimm@gmail.com
maintainer: atreyu.bbb@gmail.com
copyright: The Haskell IDE Team
category: Development
build-type: Simple
extra-source-files:
LICENSE
test/testdata/**/*.yaml
-- this one is not matched by the previous glob
test/testdata/ignore/.hlint.yaml
test/testdata/**/*.hs
test/testdata/**/*.h

flag pedantic
description: Enable -Werror
Expand Down Expand Up @@ -101,3 +108,21 @@ library
default-extensions:
DataKinds
TypeOperators

test-suite tests
type: exitcode-stdio-1.0
default-language: Haskell2010
hs-source-dirs: test
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
aeson
, base
, containers
, filepath
, hls-hlint-plugin
, hls-plugin-api
, hls-test-utils >=1.0 && <1.2
, lens
, lsp-types
, text
Loading