Skip to content

Commit e6f3ed3

Browse files
authored
Merge branch 'master' into enhance/gha-update-haskell-actions
2 parents 75a59ab + 93b6bf5 commit e6f3ed3

16 files changed

+1505
-18
lines changed

haskell-language-server.cabal

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ common floskell
314314
cpp-options: -Dhls_floskell
315315

316316
common fourmolu
317-
if flag(fourmolu)
317+
if flag(fourmolu)
318318
build-depends: hls-fourmolu-plugin == 2.5.0.0
319319
cpp-options: -Dhls_fourmolu
320320

321321
common ormolu
322-
if flag(ormolu)
322+
if flag(ormolu)
323323
build-depends: hls-ormolu-plugin == 2.5.0.0
324324
cpp-options: -Dhls_ormolu
325325

@@ -522,7 +522,6 @@ test-suite func-test
522522
, data-default
523523
, deepseq
524524
, hashable
525-
, hspec-expectations
526525
, lens
527526
, lens-aeson
528527
, ghcide
@@ -541,6 +540,7 @@ test-suite func-test
541540
main-is: Main.hs
542541
other-modules:
543542
Config
543+
ConfigSchema
544544
Format
545545
FunctionalBadProject
546546
HieBios
@@ -556,7 +556,7 @@ test-suite func-test
556556
if flag(eval)
557557
cpp-options: -Dhls_eval
558558
-- formatters
559-
if flag(floskell)
559+
if flag(floskell)
560560
cpp-options: -Dhls_floskell
561561
if flag(fourmolu)
562562
cpp-options: -Dhls_fourmolu

test/functional/ConfigSchema.hs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
module ConfigSchema where
2+
3+
4+
import qualified Data.ByteString.Lazy.Char8 as BS
5+
import Data.Char (toLower)
6+
import System.FilePath ((</>))
7+
import System.Process.Extra
8+
import Test.Hls
9+
import Test.Hls.Command
10+
11+
-- | Integration test to capture changes to the generated default config and the vscode schema.
12+
--
13+
-- Changes to the vscode schema need to be communicated to vscode-haskell plugin maintainers,
14+
-- otherwise users can't make use of the new configurations.
15+
--
16+
-- In general, changes to the schema need to be done consciously when new plugin or features are added.
17+
-- To fix a failing of these tests, review the change. If it is expected, accept the change via:
18+
--
19+
-- @
20+
-- TASTY_PATTERN="generate schema" cabal test func-test --test-options=--accept
21+
-- @
22+
--
23+
-- As changes need to be applied for all GHC version specific configs, you either need to run this command for each
24+
-- GHC version that is affected by the config change, or manually add the change to all other golden config files.
25+
-- Likely, the easiest way is to run CI and apply the generated diffs manually.
26+
tests :: TestTree
27+
tests = testGroup "generate schema"
28+
[ goldenGitDiff "vscode-extension-schema" (vscodeSchemaFp ghcVersion) $ do
29+
stdout <- readProcess hlsExeCommand ["vscode-extension-schema"] ""
30+
pure $ BS.pack stdout
31+
, goldenGitDiff "generate-default-config" (defaultConfigFp ghcVersion) $ do
32+
stdout <- readProcess hlsExeCommand ["generate-default-config"] ""
33+
pure $ BS.pack stdout
34+
]
35+
36+
vscodeSchemaFp :: GhcVersion -> FilePath
37+
vscodeSchemaFp ghcVer = "test" </> "testdata" </> "schema" </> prettyGhcVersion ghcVer </> vscodeSchemaJson
38+
39+
defaultConfigFp :: GhcVersion -> FilePath
40+
defaultConfigFp ghcVer = "test" </> "testdata" </> "schema" </> prettyGhcVersion ghcVer </> generateDefaultConfigJson
41+
42+
vscodeSchemaJson :: FilePath
43+
vscodeSchemaJson = "vscode-extension-schema.golden.json"
44+
45+
generateDefaultConfigJson :: FilePath
46+
generateDefaultConfigJson = "default-config.golden.json"
47+
48+
prettyGhcVersion :: GhcVersion -> String
49+
prettyGhcVersion ghcVer = map toLower (show ghcVer)

test/functional/Format.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tests = testGroup "format document"
2323

2424
providerTests :: TestTree
2525
providerTests = testGroup "lsp formatting provider"
26-
[ testCase "respects none" $ runSessionWithConfig (formatConfig "none") hlsCommand fullCaps "test/testdata/format" $ do
26+
[ testCase "respects none" $ runSessionWithConfig (formatConfig "none") hlsLspCommand fullCaps "test/testdata/format" $ do
2727
void configurationRequest
2828
doc <- openDoc "Format.hs" "haskell"
2929
resp <- request SMethod_TextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing)
@@ -34,7 +34,7 @@ providerTests = testGroup "lsp formatting provider"
3434
_ -> assertFailure $ "strange response from formatting provider:" ++ show result
3535
result -> assertFailure $ "strange response from formatting provider:" ++ show result
3636

37-
, requiresOrmoluPlugin . requiresFloskellPlugin $ testCase "can change on the fly" $ runSessionWithConfig (formatConfig "none") hlsCommand fullCaps "test/testdata/format" $ do
37+
, requiresOrmoluPlugin . requiresFloskellPlugin $ testCase "can change on the fly" $ runSessionWithConfig (formatConfig "none") hlsLspCommand fullCaps "test/testdata/format" $ do
3838
void configurationRequest
3939
formattedOrmolu <- liftIO $ T.readFile "test/testdata/format/Format.ormolu.formatted.hs"
4040
formattedFloskell <- liftIO $ T.readFile "test/testdata/format/Format.floskell.formatted.hs"

test/functional/FunctionalBadProject.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import Test.Hls.Command
1212
tests :: TestTree
1313
tests = testGroup "behaviour on malformed projects"
1414
[ testCase "Missing module diagnostic" $ do
15-
runSession hlsCommand fullCaps "test/testdata/missingModuleTest/missingModule/" $ do
15+
runSession hlsLspCommand fullCaps "test/testdata/missingModuleTest/missingModule/" $ do
1616
doc <- openDoc "src/MyLib.hs" "haskell"
1717
[diag] <- waitForDiagnosticsFrom doc
1818
liftIO $ assertBool "missing module name" $ "MyLib" `T.isInfixOf` (diag ^. L.message)
1919
liftIO $ assertBool "module missing context" $ "may not be listed" `T.isInfixOf` (diag ^. L.message)
2020
, testCase "Missing module diagnostic - no matching prefix" $ do
21-
runSession hlsCommand fullCaps "test/testdata/missingModuleTest/noPrefixMatch/" $ do
21+
runSession hlsLspCommand fullCaps "test/testdata/missingModuleTest/noPrefixMatch/" $ do
2222
doc <- openDoc "app/Other.hs" "haskell"
2323
[diag] <- waitForDiagnosticsFrom doc
2424
liftIO $ assertBool "missing module name" $

test/functional/HieBios.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Test.Hls.Command
1111
tests :: TestTree
1212
tests = testGroup "hie-bios"
1313
[ testCase "loads main-is module" $ do
14-
runSession hlsCommand fullCaps "test/testdata/hieBiosMainIs" $ do
14+
runSession hlsLspCommand fullCaps "test/testdata/hieBiosMainIs" $ do
1515
_ <- openDoc "Main.hs" "haskell"
1616
(diag:_) <- waitForDiagnostics
1717
liftIO $ "Top-level binding with no type signature:" `T.isInfixOf` (diag ^. L.message)

test/functional/Main.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Main where
22

33
import Config
4+
import ConfigSchema
45
import Format
56
import FunctionalBadProject
67
import HieBios
@@ -10,6 +11,7 @@ import Test.Hls
1011
main :: IO ()
1112
main = defaultTestRunner $ testGroup "haskell-language-server"
1213
[ Config.tests
14+
, ConfigSchema.tests
1315
, ignoreInEnv [HostOS Windows, GhcVer GHC90, GhcVer GHC92] "Tests gets stuck in ci" $ Format.tests
1416
, FunctionalBadProject.tests
1517
, HieBios.tests

test/functional/Progress.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ tests =
2828
testGroup
2929
"window/workDoneProgress"
3030
[ testCase "sends indefinite progress notifications" $
31-
runSession hlsCommand progressCaps "test/testdata/diagnostics" $ do
31+
runSession hlsLspCommand progressCaps "test/testdata/diagnostics" $ do
3232
let path = "Foo.hs"
3333
_ <- openDoc path "haskell"
3434
expectProgressMessages [pack ("Setting up diagnostics (for " ++ path ++ ")"), "Processing", "Indexing"] []
3535
, requiresEvalPlugin $ testCase "eval plugin sends progress reports" $
36-
runSession hlsCommand progressCaps "plugins/hls-eval-plugin/test/testdata" $ do
36+
runSession hlsLspCommand progressCaps "plugins/hls-eval-plugin/test/testdata" $ do
3737
doc <- openDoc "T1.hs" "haskell"
3838
lspId <- sendRequest SMethod_TextDocumentCodeLens (CodeLensParams Nothing Nothing doc)
3939

@@ -57,15 +57,15 @@ tests =
5757
expectProgressMessages ["Evaluating"] activeProgressTokens
5858
_ -> error $ "Unexpected response result: " ++ show response
5959
, requiresOrmoluPlugin $ testCase "ormolu plugin sends progress notifications" $ do
60-
runSessionWithConfig (def { ignoreConfigurationRequests = False }) hlsCommand progressCaps "test/testdata/format" $ do
60+
runSessionWithConfig (def { ignoreConfigurationRequests = False }) hlsLspCommand progressCaps "test/testdata/format" $ do
6161
void configurationRequest
6262
setHlsConfig (formatLspConfig "ormolu")
6363
doc <- openDoc "Format.hs" "haskell"
6464
expectProgressMessages ["Setting up testdata (for Format.hs)", "Processing", "Indexing"] []
6565
_ <- sendRequest SMethod_TextDocumentFormatting $ DocumentFormattingParams Nothing doc (FormattingOptions 2 True Nothing Nothing Nothing)
6666
expectProgressMessages ["Formatting Format.hs"] []
6767
, requiresFourmoluPlugin $ testCase "fourmolu plugin sends progress notifications" $ do
68-
runSessionWithConfig (def { ignoreConfigurationRequests = False }) hlsCommand progressCaps "test/testdata/format" $ do
68+
runSessionWithConfig (def { ignoreConfigurationRequests = False }) hlsLspCommand progressCaps "test/testdata/format" $ do
6969
void configurationRequest
7070
setHlsConfig (formatLspConfig "fourmolu")
7171
doc <- openDoc "Format.hs" "haskell"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{
2+
"checkParents": "CheckOnSave",
3+
"checkProject": true,
4+
"formattingProvider": "ormolu",
5+
"maxCompletions": 40,
6+
"plugin": {
7+
"alternateNumberFormat": {
8+
"globalOn": true
9+
},
10+
"cabal": {
11+
"codeActionsOn": true,
12+
"completionOn": true
13+
},
14+
"callHierarchy": {
15+
"globalOn": true
16+
},
17+
"changeTypeSignature": {
18+
"globalOn": true
19+
},
20+
"class": {
21+
"codeActionsOn": true,
22+
"codeLensOn": true
23+
},
24+
"eval": {
25+
"config": {
26+
"diff": true,
27+
"exception": false
28+
},
29+
"globalOn": true
30+
},
31+
"explicit-fields": {
32+
"globalOn": true
33+
},
34+
"explicit-fixity": {
35+
"globalOn": true
36+
},
37+
"fourmolu": {
38+
"config": {
39+
"external": false
40+
}
41+
},
42+
"gadt": {
43+
"globalOn": true
44+
},
45+
"ghcide-code-actions-bindings": {
46+
"globalOn": true
47+
},
48+
"ghcide-code-actions-fill-holes": {
49+
"globalOn": true
50+
},
51+
"ghcide-code-actions-imports-exports": {
52+
"globalOn": true
53+
},
54+
"ghcide-code-actions-type-signatures": {
55+
"globalOn": true
56+
},
57+
"ghcide-completions": {
58+
"config": {
59+
"autoExtendOn": true,
60+
"snippetsOn": true
61+
},
62+
"globalOn": true
63+
},
64+
"ghcide-hover-and-symbols": {
65+
"hoverOn": true,
66+
"symbolsOn": true
67+
},
68+
"ghcide-type-lenses": {
69+
"config": {
70+
"mode": "always"
71+
},
72+
"globalOn": true
73+
},
74+
"hlint": {
75+
"codeActionsOn": true,
76+
"config": {
77+
"flags": []
78+
},
79+
"diagnosticsOn": true
80+
},
81+
"importLens": {
82+
"codeActionsOn": true,
83+
"codeLensOn": true
84+
},
85+
"moduleName": {
86+
"globalOn": true
87+
},
88+
"ormolu": {
89+
"config": {
90+
"external": false
91+
}
92+
},
93+
"overloaded-record-dot": {
94+
"globalOn": true
95+
},
96+
"pragmas-completion": {
97+
"globalOn": true
98+
},
99+
"pragmas-disable": {
100+
"globalOn": true
101+
},
102+
"pragmas-suggest": {
103+
"globalOn": true
104+
},
105+
"qualifyImportedNames": {
106+
"globalOn": true
107+
},
108+
"rename": {
109+
"config": {
110+
"crossModule": false
111+
},
112+
"globalOn": true
113+
},
114+
"retrie": {
115+
"globalOn": true
116+
},
117+
"splice": {
118+
"globalOn": true
119+
}
120+
}
121+
}

0 commit comments

Comments
 (0)