Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 72bf4c7

Browse files
committed
Update most tests for GHC 8.6.2
One still fails, but I suspect the lsp-test codeAction catcher is broken, the message is in the log, but not picked up by testing.
1 parent 8e4da98 commit 72bf4c7

File tree

3 files changed

+73
-57
lines changed

3 files changed

+73
-57
lines changed

stack-8.6.2.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: nightly-2018-11-13 # GHC 8.6.2
1+
resolver: nightly-2018-11-24 # GHC 8.6.2
22
packages:
33
- .
44
- hie-plugin-api
@@ -10,35 +10,27 @@ extra-deps:
1010
- ./submodules/ghc-mod
1111
- ./submodules/ghc-mod/core
1212

13+
- Cabal-2.4.1.0
1314
- apply-refact-0.6.0.0
1415
- butcher-1.3.2.1
15-
- cabal-install-2.4.0.0
16+
- cabal-install-2.4.1.0
1617
- cabal-plan-0.4.0.0
1718
- constrained-dynamic-0.1.0.0
18-
- cryptohash-sha256-0.11.101.0
19-
- czipwith-1.0.1.1
20-
- data-tree-print-0.1.0.2
21-
- ed25519-0.0.5.0
22-
- ekg-core-0.1.1.4
2319
- ekg-json-0.1.0.6
2420
- ekg-wai-0.1.0.3
25-
- hackage-security-0.5.3.0
2621
- haddock-api-2.21.0
27-
- haskell-lsp-0.8.0.1
28-
- haskell-lsp-types-0.8.0.1
2922
- hsimport-0.8.6
3023
- lsp-test-0.5.0.1
3124
- monad-memo-0.4.1
32-
- monoid-subclasses-0.4.6.1
3325
- multistate-0.8.0.1
34-
- primes-0.2.1.0
3526
- resolv-0.1.1.2
3627
- syz-0.2.0.0
3728
- temporary-1.2.1.1
3829
- yaml-0.8.32
3930

4031

4132

33+
4234
flags:
4335
haskell-ide-engine:
4436
pedantic: true
@@ -55,7 +47,7 @@ flags:
5547
# process:
5648
# allow-newer: true
5749

58-
allow-newer: true
50+
# allow-newer: true
5951

6052
nix:
6153
packages: [ icu libcxx zlib ]

test/functional/FunctionalCodeActionsSpec.hs

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE CPP #-}
21
{-# LANGUAGE OverloadedStrings #-}
32

43
module FunctionalCodeActionsSpec where
@@ -136,11 +135,11 @@ spec = describe "code actions" $ do
136135
[_,diag:_] <- count 2 waitForDiagnostics
137136

138137

139-
#if __GLASGOW_HASKELL__ >= 806
140-
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not load module \8216Data.Text\8217"
141-
#else
142-
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not find module ‘Data.Text’"
143-
#endif
138+
if ghcVersion == GHC86
139+
then
140+
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not load module \8216Data.Text\8217"
141+
else
142+
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not find module ‘Data.Text’"
144143

145144
liftIO $ putStrLn $ "add package suggestions:waiting for code actions" -- AZ
146145
acts <- getAllCodeActions doc
@@ -165,11 +164,11 @@ spec = describe "code actions" $ do
165164
-- ignore the first empty hlint diagnostic publish
166165
[_,diag:_] <- count 2 waitForDiagnostics
167166

168-
#if __GLASGOW_HASKELL__ >= 806
169-
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not load module ‘Codec.Compression.GZip’"
170-
#else
171-
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not find module ‘Codec.Compression.GZip’"
172-
#endif
167+
if ghcVersion == GHC86
168+
then
169+
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not load module ‘Codec.Compression.GZip’"
170+
else
171+
liftIO $ diag ^. L.message `shouldSatisfy` T.isPrefixOf "Could not find module ‘Codec.Compression.GZip’"
173172

174173
mActions <- getAllCodeActions doc
175174
let allActions = map fromAction mActions
@@ -246,19 +245,28 @@ spec = describe "code actions" $ do
246245
cas <- map (\(CACodeAction x)-> x) <$> getAllCodeActions doc
247246

248247
suggestion <-
249-
if ghc84 then do
250-
liftIO $ map (^. L.title) cas `shouldMatchList`
251-
[ "Substitute hole (Int) with maxBound (forall a. Bounded a => a)"
252-
, "Substitute hole (Int) with minBound (forall a. Bounded a => a)"
253-
, "Substitute hole (Int) with undefined (forall (a :: TYPE r). GHC.Stack.Types.HasCallStack => a)"
254-
]
255-
return "maxBound"
256-
else do
257-
liftIO $ map (^. L.title) cas `shouldMatchList`
258-
[ "Substitute hole (Int) with x ([Int])"
259-
, "Substitute hole (Int) with foo ([Int] -> Int)"
260-
]
261-
return "x"
248+
case ghcVersion of
249+
GHC86 -> do
250+
liftIO $ map (^. L.title) cas `shouldMatchList`
251+
[ "Substitute hole (Int) with x ([Int])"
252+
, "Substitute hole (Int) with foo ([Int] -> Int Valid hole fits include)"
253+
, "Substitute hole (Int) with maxBound (forall a. Bounded a => a with maxBound @Int)"
254+
, "Substitute hole (Int) with minBound (forall a. Bounded a => a with minBound @Int)"
255+
]
256+
return "x"
257+
GHC84 -> do
258+
liftIO $ map (^. L.title) cas `shouldMatchList`
259+
[ "Substitute hole (Int) with maxBound (forall a. Bounded a => a)"
260+
, "Substitute hole (Int) with minBound (forall a. Bounded a => a)"
261+
, "Substitute hole (Int) with undefined (forall (a :: TYPE r). GHC.Stack.Types.HasCallStack => a)"
262+
]
263+
return "maxBound"
264+
GHCPre84 -> do
265+
liftIO $ map (^. L.title) cas `shouldMatchList`
266+
[ "Substitute hole (Int) with x ([Int])"
267+
, "Substitute hole (Int) with foo ([Int] -> Int)"
268+
]
269+
return "x"
262270

263271
executeCodeAction $ head cas
264272

@@ -276,21 +284,29 @@ spec = describe "code actions" $ do
276284
cas <- map fromAction <$> getAllCodeActions doc
277285

278286
suggestion <-
279-
if ghc84 then do
280-
liftIO $ map (^. L.title) cas `shouldMatchList`
281-
[ "Substitute hole (A) with undefined (forall (a :: TYPE r). GHC.Stack.Types.HasCallStack => a)"
282-
, "Substitute hole (A) with stuff (A -> A)"
283-
, "Substitute hole (A) with x ([A])"
284-
, "Substitute hole (A) with foo2 ([A] -> A)"
285-
]
286-
return "undefined"
287-
else do
288-
liftIO $ map (^. L.title) cas `shouldMatchList`
289-
[ "Substitute hole (A) with stuff (A -> A)"
290-
, "Substitute hole (A) with x ([A])"
291-
, "Substitute hole (A) with foo2 ([A] -> A)"
292-
]
293-
return "stuff"
287+
case ghcVersion of
288+
GHC86 -> do
289+
liftIO $ map (^. L.title) cas `shouldMatchList`
290+
[ "Substitute hole (A) with stuff (A -> A)"
291+
, "Substitute hole (A) with x ([A])"
292+
, "Substitute hole (A) with foo2 ([A] -> A)"
293+
]
294+
return "stuff"
295+
GHC84 -> do
296+
liftIO $ map (^. L.title) cas `shouldMatchList`
297+
[ "Substitute hole (A) with undefined (forall (a :: TYPE r). GHC.Stack.Types.HasCallStack => a)"
298+
, "Substitute hole (A) with stuff (A -> A)"
299+
, "Substitute hole (A) with x ([A])"
300+
, "Substitute hole (A) with foo2 ([A] -> A)"
301+
]
302+
return "undefined"
303+
GHCPre84 -> do
304+
liftIO $ map (^. L.title) cas `shouldMatchList`
305+
[ "Substitute hole (A) with stuff (A -> A)"
306+
, "Substitute hole (A) with x ([A])"
307+
, "Substitute hole (A) with foo2 ([A] -> A)"
308+
]
309+
return "stuff"
294310

295311
executeCodeAction $ head cas
296312

test/utils/TestUtils.hs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module TestUtils
1010
, makeRequest
1111
, dummyVfs
1212
, runIGM
13-
, ghc84
13+
, ghcVersion, GhcVersion(..)
1414
, logFilePath
1515
, hieCommand
1616
, hieCommandVomit
@@ -120,11 +120,19 @@ files =
120120
, "./test/testdata/wErrorTest/"
121121
]
122122

123-
ghc84 :: Bool
124-
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,4,0,0)))
125-
ghc84 = True
123+
data GhcVersion
124+
= GHC86
125+
| GHC84
126+
| GHCPre84
127+
deriving (Eq,Show)
128+
129+
ghcVersion :: GhcVersion
130+
#if (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,6,0,0)))
131+
ghcVersion = GHC86
132+
#elif (defined(MIN_VERSION_GLASGOW_HASKELL) && (MIN_VERSION_GLASGOW_HASKELL(8,4,0,0)))
133+
ghcVersion = GHC84
126134
#else
127-
ghc84 = False
135+
ghcVersion = GHCPre84
128136
#endif
129137

130138
stackYaml :: FilePath

0 commit comments

Comments
 (0)