Skip to content

Commit 0adf4bd

Browse files
authored
Merge pull request #260 from bubba/remove-hspec-expectations
Remove hspec-expectations
2 parents bd5e256 + 6b51c7c commit 0adf4bd

16 files changed

+284
-285
lines changed

haskell-language-server.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ test-suite func-test
244244
, haskell-language-server
245245
, haskell-lsp
246246
, haskell-lsp-types
247-
, hspec-expectations
248247
, lens
249248
, lsp-test >= 0.11.0.3
250249
, tasty

test/functional/Command.hs

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Test.Hls.Util
1212
import Test.Tasty
1313
import Test.Tasty.HUnit
1414
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
15-
import Test.Hspec.Expectations
1615

1716

1817
--TODO : Response Message no longer has 4 inputs
@@ -24,8 +23,8 @@ tests = testGroup "commands" [
2423
let List cmds = res ^. LSP.capabilities . executeCommandProvider . _Just . commands
2524
f x = (T.length (T.takeWhile isNumber x) >= 1) && (T.count ":" x >= 2)
2625
liftIO $ do
27-
cmds `shouldSatisfy` all f
28-
cmds `shouldNotSatisfy` null
26+
all f cmds @? "All prefixed"
27+
not (null cmds) @? "Commands aren't empty"
2928
, ignoreTestBecause "Broken: Plugin package doesn't exist" $
3029
testCase "get de-prefixed" $
3130
runSession hieCommand fullCaps "test/testdata/" $ do
@@ -34,5 +33,5 @@ tests = testGroup "commands" [
3433
(ExecuteCommandParams "1234:package:add" (Just (List [])) Nothing) :: Session ExecuteCommandResponse
3534
let ResponseError _ msg _ = err
3635
-- 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"
36+
liftIO $ (msg `T.isInfixOf` "while parsing args for add in plugin package") @? "Has error message"
3837
]

test/functional/Completion.hs

+74-75
Large diffs are not rendered by default.

test/functional/Deferred.hs

+12-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Test.Hls.Util
1616
import Test.Tasty
1717
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
1818
import Test.Tasty.HUnit
19-
import Test.Hspec.Expectations
2019

2120

2221
tests :: TestTree
@@ -30,16 +29,16 @@ tests = testGroup "deferred responses" [
3029

3130
-- skipMany anyNotification
3231
-- hoverRsp <- message :: Session HoverResponse
33-
-- liftIO $ hoverRsp ^? result . _Just . _Just . contents `shouldBe` Nothing
34-
-- liftIO $ hoverRsp ^. LSP.id `shouldBe` responseId id1
32+
-- liftIO $ hoverRsp ^? result . _Just . _Just . contents @?= Nothing
33+
-- liftIO $ hoverRsp ^. LSP.id @?= responseId id1
3534

3635
-- id2 <- sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc Nothing)
3736
-- symbolsRsp <- skipManyTill anyNotification message :: Session DocumentSymbolsResponse
38-
-- liftIO $ symbolsRsp ^. LSP.id `shouldBe` responseId id2
37+
-- liftIO $ symbolsRsp ^. LSP.id @?= responseId id2
3938

4039
-- id3 <- sendRequest TextDocumentHover (TextDocumentPositionParams doc (Position 4 2) Nothing)
4140
-- hoverRsp2 <- skipManyTill anyNotification message :: Session HoverResponse
42-
-- liftIO $ hoverRsp2 ^. LSP.id `shouldBe` responseId id3
41+
-- liftIO $ hoverRsp2 ^. LSP.id @?= responseId id3
4342

4443
-- let contents2 = hoverRsp2 ^? result . _Just . _Just . contents
4544
-- liftIO $ contents2 `shouldNotSatisfy` null
@@ -48,7 +47,7 @@ tests = testGroup "deferred responses" [
4847
-- let highlightParams = TextDocumentPositionParams doc (Position 7 0) Nothing
4948
-- highlightRsp <- request TextDocumentDocumentHighlight highlightParams
5049
-- let (Just (List locations)) = highlightRsp ^. result
51-
-- liftIO $ locations `shouldBe` [ DocumentHighlight
50+
-- liftIO $ locations @?= [ DocumentHighlight
5251
-- { _range = Range
5352
-- { _start = Position {_line = 7, _character = 0}
5453
-- , _end = Position {_line = 7, _character = 2}
@@ -95,15 +94,15 @@ tests = testGroup "deferred responses" [
9594
testCase "instantly respond to failed modules with no cache" $ runSession hieCommand fullCaps "test/testdata" $ do
9695
doc <- openDoc "FuncTestFail.hs" "haskell"
9796
defs <- getDefinitions doc (Position 1 11)
98-
liftIO $ defs `shouldBe` []
97+
liftIO $ defs @?= []
9998

10099
-- TODO: the benefits of caching parsed modules is doubted.
101100
-- TODO: add issue link
102101
-- , testCase "respond to untypecheckable modules with parsed module cache" $
103102
-- runSession hieCommand fullCaps "test/testdata" $ do
104103
-- doc <- openDoc "FuncTestFail.hs" "haskell"
105104
-- (Left (sym:_)) <- getDocumentSymbols doc
106-
-- liftIO $ sym ^. name `shouldBe` "main"
105+
-- liftIO $ sym ^. name @?= "main"
107106

108107
-- TODO does not compile
109108
-- , testCase "returns hints as diagnostics" $ runSession hieCommand fullCaps "test/testdata" $ do
@@ -113,7 +112,7 @@ tests = testGroup "deferred responses" [
113112
-- let testUri = filePathToUri $ cwd </> "test/testdata/FuncTest.hs"
114113

115114
-- diags <- skipManyTill loggingNotification publishDiagnosticsNotification
116-
-- liftIO $ diags ^? params `shouldBe` (Just $ PublishDiagnosticsParams
115+
-- liftIO $ diags ^? params @?= (Just $ PublishDiagnosticsParams
117116
-- { _uri = testUri
118117
-- , _diagnostics = List
119118
-- [ Diagnostic
@@ -130,12 +129,12 @@ tests = testGroup "deferred responses" [
130129
-- args = List [Object args']
131130
--
132131
-- executeRsp <- request WorkspaceExecuteCommand (ExecuteCommandParams "hare:demote" (Just args) Nothing)
133-
-- liftIO $ executeRsp ^. result `shouldBe` Just (Object H.empty)
132+
-- liftIO $ executeRsp ^. result @?= Just (Object H.empty)
134133

135134
-- editReq <- message :: Session ApplyWorkspaceEditRequest
136135
-- let expectedTextEdits = List [TextEdit (Range (Position 6 0) (Position 7 6)) " where\n bb = 5"]
137136
-- expectedTextDocEdits = List [TextDocumentEdit (VersionedTextDocumentIdentifier testUri (Just 0)) expectedTextEdits]
138-
-- liftIO $ editReq ^. params . edit `shouldBe` WorkspaceEdit
137+
-- liftIO $ editReq ^. params . edit @?= WorkspaceEdit
139138
-- Nothing
140139
-- (Just expectedTextDocEdits)
141140
-- , multiServerTests
@@ -165,13 +164,13 @@ multiMainTests = testGroup "multiple main modules" [
165164
diagsRspGhc <- skipManyTill anyNotification message :: Session PublishDiagnosticsNotification
166165
let (List diags) = diagsRspGhc ^. params . diagnostics
167166

168-
liftIO $ length diags `shouldBe` 2
167+
liftIO $ length diags @?= 2
169168

170169
_doc2 <- openDoc "HaReRename.hs" "haskell"
171170
_diagsRspHlint2 <- skipManyTill anyNotification message :: Session PublishDiagnosticsNotification
172171
-- errMsg <- skipManyTill anyNotification notification :: Session ShowMessageNotification
173172
diagsRsp2 <- skipManyTill anyNotification message :: Session PublishDiagnosticsNotification
174173
let (List diags2) = diagsRsp2 ^. params . diagnostics
175174

176-
liftIO $ show diags2 `shouldBe` "[]"
175+
liftIO $ show diags2 @?= "[]"
177176
]

test/functional/Definition.hs

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Test.Hls.Util
1010
import Test.Tasty
1111
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
1212
import Test.Tasty.HUnit
13-
import Test.Hspec.Expectations
1413

1514
tests :: TestTree
1615
tests = testGroup "definitions" [
@@ -20,7 +19,7 @@ tests = testGroup "definitions" [
2019
doc <- openDoc "References.hs" "haskell"
2120
defs <- getDefinitions doc (Position 7 8)
2221
let expRange = Range (Position 4 0) (Position 4 3)
23-
liftIO $ defs `shouldBe` [Location (doc ^. uri) expRange]
22+
liftIO $ defs @?= [Location (doc ^. uri) expRange]
2423

2524
-- -----------------------------------
2625

@@ -30,15 +29,15 @@ tests = testGroup "definitions" [
3029
defs <- getDefinitions doc (Position 2 8)
3130
liftIO $ do
3231
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
33-
defs `shouldBe` [Location (filePathToUri fp) zeroRange]
32+
defs @?= [Location (filePathToUri fp) zeroRange]
3433

3534
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
3635
testCase "goto's exported modules" $ runSession hieCommand fullCaps "test/testdata/definition" $ do
3736
doc <- openDoc "Foo.hs" "haskell"
3837
defs <- getDefinitions doc (Position 0 15)
3938
liftIO $ do
4039
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
41-
defs `shouldBe` [Location (filePathToUri fp) zeroRange]
40+
defs @?= [Location (filePathToUri fp) zeroRange]
4241

4342
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
4443
testCase "goto's imported modules that are loaded" $ runSession hieCommand fullCaps "test/testdata/definition" $ do
@@ -47,7 +46,7 @@ tests = testGroup "definitions" [
4746
defs <- getDefinitions doc (Position 2 8)
4847
liftIO $ do
4948
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
50-
defs `shouldBe` [Location (filePathToUri fp) zeroRange]
49+
defs @?= [Location (filePathToUri fp) zeroRange]
5150

5251
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
5352
testCase "goto's imported modules that are loaded, and then closed" $
@@ -60,7 +59,7 @@ tests = testGroup "definitions" [
6059
liftIO $ putStrLn "D"
6160
liftIO $ do
6261
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
63-
defs `shouldBe` [Location (filePathToUri fp) zeroRange]
62+
defs @?= [Location (filePathToUri fp) zeroRange]
6463
liftIO $ putStrLn "E" -- AZ
6564

6665
noDiagnostics

test/functional/Diagnostic.hs

+15-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import Test.Hls.Util
1717
import Test.Tasty
1818
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
1919
import Test.Tasty.HUnit
20-
import Test.Hspec.Expectations
2120

2221
-- ---------------------------------------------------------------------
2322

@@ -41,26 +40,26 @@ triggerTests = testGroup "diagnostics triggers" [
4140
diags@(reduceDiag:_) <- waitForDiagnostics
4241

4342
liftIO $ do
44-
length diags `shouldBe` 2
45-
reduceDiag ^. LSP.range `shouldBe` Range (Position 1 0) (Position 1 12)
46-
reduceDiag ^. LSP.severity `shouldBe` Just DsInfo
47-
reduceDiag ^. LSP.code `shouldBe` Just (StringValue "Eta reduce")
48-
reduceDiag ^. LSP.source `shouldBe` Just "hlint"
43+
length diags @?= 2
44+
reduceDiag ^. LSP.range @?= Range (Position 1 0) (Position 1 12)
45+
reduceDiag ^. LSP.severity @?= Just DsInfo
46+
reduceDiag ^. LSP.code @?= Just (StringValue "Eta reduce")
47+
reduceDiag ^. LSP.source @?= Just "hlint"
4948

5049
diags2a <- waitForDiagnostics
5150

52-
liftIO $ length diags2a `shouldBe` 2
51+
liftIO $ length diags2a @?= 2
5352

5453
sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc)
5554

5655
diags3@(d:_) <- waitForDiagnosticsSource "eg2"
5756

5857
liftIO $ do
59-
length diags3 `shouldBe` 1
60-
d ^. LSP.range `shouldBe` Range (Position 0 0) (Position 1 0)
61-
d ^. LSP.severity `shouldBe` Nothing
62-
d ^. LSP.code `shouldBe` Nothing
63-
d ^. LSP.message `shouldBe` T.pack "Example plugin diagnostic, triggered byDiagnosticOnSave"
58+
length diags3 @?= 1
59+
d ^. LSP.range @?= Range (Position 0 0) (Position 1 0)
60+
d ^. LSP.severity @?= Nothing
61+
d ^. LSP.code @?= Nothing
62+
d ^. LSP.message @?= T.pack "Example plugin diagnostic, triggered byDiagnosticOnSave"
6463
]
6564

6665
errorTests :: TestTree
@@ -69,7 +68,7 @@ errorTests = testGroup "typed hole errors" [
6968
runSession hieCommand fullCaps "test/testdata" $ do
7069
_ <- openDoc "TypedHoles.hs" "haskell"
7170
[diag] <- waitForDiagnosticsSource "bios"
72-
liftIO $ diag ^. LSP.severity `shouldBe` Just DsWarning
71+
liftIO $ diag ^. LSP.severity @?= Just DsWarning
7372
]
7473

7574
warningTests :: TestTree
@@ -78,7 +77,7 @@ warningTests = testGroup "Warnings are warnings" [
7877
runSession hieCommand fullCaps "test/testdata/wErrorTest" $ do
7978
_ <- openDoc "src/WError.hs" "haskell"
8079
[diag] <- waitForDiagnosticsSource "bios"
81-
liftIO $ diag ^. LSP.severity `shouldBe` Just DsWarning
80+
liftIO $ diag ^. LSP.severity @?= Just DsWarning
8281
]
8382

8483
saveTests :: TestTree
@@ -91,7 +90,7 @@ saveTests = testGroup "only diagnostics on save" [
9190
diags <- waitForDiagnostics
9291

9392
liftIO $ do
94-
length diags `shouldBe` 0
93+
length diags @?= 0
9594

9695
let te = TextEdit (Range (Position 0 0) (Position 0 13)) ""
9796
_ <- applyEdit doc te
@@ -100,5 +99,5 @@ saveTests = testGroup "only diagnostics on save" [
10099
sendNotification TextDocumentDidSave (DidSaveTextDocumentParams doc)
101100
diags2 <- waitForDiagnostics
102101
liftIO $
103-
length diags2 `shouldBe` 1
102+
length diags2 @?= 1
104103
]

test/functional/Format.hs

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ stylishHaskellTests = testGroup "stylish-haskell" [
113113
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
114114
]
115115

116+
#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL)
117+
#else
116118
brittanyTests :: TestTree
117119
brittanyTests = testGroup "brittany" [
118120
goldenVsStringDiff "formats a document with LF endings" goldenGitDiff "test/testdata/BrittanyLF.formatted_document.hs" $ runSession hieCommand fullCaps "test/testdata" $ do
@@ -141,6 +143,7 @@ brittanyTests = testGroup "brittany" [
141143
formatRange doc (FormattingOptions 4 True) range
142144
BS.fromStrict . T.encodeUtf8 <$> documentContents doc
143145
]
146+
#endif
144147

145148
ormoluTests :: TestTree
146149
ormoluTests = testGroup "ormolu"
@@ -159,9 +162,12 @@ ormoluTests = testGroup "ormolu"
159162
formatLspConfig :: Value -> Value
160163
formatLspConfig provider = object [ "haskell" .= object ["formattingProvider" .= (provider :: Value)] ]
161164

165+
#if MIN_VERSION_GLASGOW_HASKELL(8,10,0,0) || !defined(AGPL)
166+
#else
162167
-- | The same as 'formatLspConfig' but using the legacy section name
163168
formatLspConfigOld :: Value -> Value
164169
formatLspConfigOld provider = object [ "languageServerHaskell" .= object ["formattingProvider" .= (provider :: Value)] ]
170+
#endif
165171

166172
formatConfig :: Value -> SessionConfig
167173
formatConfig provider = defaultConfig { lspConfig = Just (formatLspConfig provider) }

test/functional/FunctionalBadProject.hs

+8-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module FunctionalBadProject (tests) where
1111
-- import Test.Hls.Util
1212
import Test.Tasty
1313
import Test.Tasty.HUnit
14-
import Test.Hspec.Expectations
1514

1615
-- ---------------------------------------------------------------------
1716
-- TODO: Currently this can not succeed, since such an error is thrown in "runActionWithContext" which
@@ -20,7 +19,7 @@ import Test.Hspec.Expectations
2019
--
2120
tests :: TestTree
2221
tests = testGroup "behaviour on malformed projects" [
23-
testCase "no test executed" $ True `shouldBe` True
22+
testCase "no test executed" $ True @?= True
2423
]
2524

2625
-- testCase "deals with cabal file with unsatisfiable dependency" $
@@ -29,14 +28,14 @@ tests = testGroup "behaviour on malformed projects" [
2928
-- _doc <- openDoc "Foo.hs" "haskell"
3029

3130
-- diags@(d:_) <- waitForDiagnosticsSource "bios"
32-
-- -- liftIO $ show diags `shouldBe` ""
31+
-- -- liftIO $ show diags @?= ""
3332
-- -- liftIO $ putStrLn $ show diags
3433
-- -- liftIO $ putStrLn "a"
3534
-- liftIO $ do
36-
-- length diags `shouldBe` 1
37-
-- d ^. range `shouldBe` Range (Position 0 0) (Position 1 0)
38-
-- d ^. severity `shouldBe` (Just DsError)
39-
-- d ^. code `shouldBe` Nothing
40-
-- d ^. source `shouldBe` Just "bios"
41-
-- d ^. message `shouldBe`
35+
-- length diags @?= 1
36+
-- d ^. range @?= Range (Position 0 0) (Position 1 0)
37+
-- d ^. severity @?= (Just DsError)
38+
-- d ^. code @?= Nothing
39+
-- d ^. source @?= Just "bios"
40+
-- d ^. message @?=
4241
-- (T.pack "readCreateProcess: stack \"build\" \"--only-configure\" \".\" (exit 1): failed\n")

0 commit comments

Comments
 (0)