Skip to content

Commit a4877b5

Browse files
committed
Add a test
1 parent d372b4b commit a4877b5

File tree

9 files changed

+55
-21
lines changed

9 files changed

+55
-21
lines changed

ghcide/src/Development/IDE/Core/Rules.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ import Ide.Plugin.Properties (HasProperty,
148148
import Ide.PluginUtils (configForPlugin)
149149
import Ide.Types (DynFlagsModifications (dynFlagsModifyGlobal, dynFlagsModifyParser),
150150
PluginId)
151-
import System.FilePath ((<.>))
152-
import GHC (ms_mod_name)
153151

154152
-- | This is useful for rules to convert rules that can only produce errors or
155153
-- a result into the more general IdeResult type that supports producing

ghcide/test/data/boot2/A.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module A where
2+
3+
-- E source imports B
4+
-- In interface file see source module dependencies: B {-# SOURCE #-}
5+
import E
6+
-- C imports B
7+
-- In interface file see source module dependencies: B
8+
import C
9+
10+
-- Instance for B only available from B.hi not B.hi-boot, so tests we load
11+
-- that.
12+
main = print B

ghcide/test/data/boot2/B.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module B where
2+
3+
import D
4+
5+
data B = B
6+
7+
instance Show B where
8+
show B = "B"

ghcide/test/data/boot2/B.hs-boot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module B where
2+
3+
data B = B

ghcide/test/data/boot2/C.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module C where
2+
3+
import B

ghcide/test/data/boot2/D.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module D where
2+
3+
import {-# SOURCE #-} B

ghcide/test/data/boot2/E.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module E(B(B)) where
2+
3+
import {-# SOURCE #-} B

ghcide/test/data/boot2/hie.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cradle: {direct: {arguments: ["A.hs", "B.hs-boot", "B.hs", "C.hs", "D.hs", "E.hs"]}}

ghcide/test/exe/Main.hs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,25 +5277,28 @@ ifaceTests = testGroup "Interface loading tests"
52775277
]
52785278

52795279
bootTests :: TestTree
5280-
bootTests = testCase "boot-def-test" $ runWithExtraFiles "boot" $ \dir -> do
5281-
let cPath = dir </> "C.hs"
5282-
cSource <- liftIO $ readFileUtf8 cPath
5283-
5284-
-- Dirty the cache
5285-
liftIO $ runInDir dir $ do
5286-
cDoc <- createDoc cPath "haskell" cSource
5287-
_ <- getHover cDoc $ Position 4 3
5288-
~() <- skipManyTill anyMessage $ satisfyMaybe $ \case
5289-
FromServerMess (SCustomMethod "ghcide/reference/ready") (NotMess NotificationMessage{_params = fp}) -> do
5290-
A.Success fp' <- pure $ fromJSON fp
5291-
if equalFilePath fp' cPath then pure () else Nothing
5292-
_ -> Nothing
5293-
closeDoc cDoc
5294-
5295-
cdoc <- createDoc cPath "haskell" cSource
5296-
locs <- getDefinitions cdoc (Position 7 4)
5297-
let floc = mkR 9 0 9 1
5298-
checkDefs locs (pure [floc])
5280+
bootTests = testGroup "boot"
5281+
[ testCase "boot-def-test" $ runWithExtraFiles "boot" $ \dir -> do
5282+
let cPath = dir </> "C.hs"
5283+
cSource <- liftIO $ readFileUtf8 cPath
5284+
-- Dirty the cache
5285+
liftIO $ runInDir dir $ do
5286+
cDoc <- createDoc cPath "haskell" cSource
5287+
_ <- getHover cDoc $ Position 4 3
5288+
~() <- skipManyTill anyMessage $ satisfyMaybe $ \case
5289+
FromServerMess (SCustomMethod "ghcide/reference/ready") (NotMess NotificationMessage{_params = fp}) -> do
5290+
A.Success fp' <- pure $ fromJSON fp
5291+
if equalFilePath fp' cPath then pure () else Nothing
5292+
_ -> Nothing
5293+
closeDoc cDoc
5294+
cdoc <- createDoc cPath "haskell" cSource
5295+
locs <- getDefinitions cdoc (Position 7 4)
5296+
let floc = mkR 9 0 9 1
5297+
checkDefs locs (pure [floc])
5298+
, testCase "graph with boot modules" $ runWithExtraFiles "boot2" $ \dir -> do
5299+
_ <- openDoc (dir </> "A.hs") "haskell"
5300+
expectNoMoreDiagnostics 2
5301+
]
52995302

53005303
-- | test that TH reevaluates across interfaces
53015304
ifaceTHTest :: TestTree

0 commit comments

Comments
 (0)