Skip to content

Commit 972767c

Browse files
committed
Add boot dependency test (failing)
1 parent 2cb5ff1 commit 972767c

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Dependency where
2+
3+
import Data.Set (Set, empty)
4+
5+
emptySet :: Set Int
6+
emptySet = empty
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages: .
2+
package *
3+
ghc-options: -fwrite-ide-info
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: dependency-boot
2+
version: 0.1.0.0
3+
cabal-version: 2.0
4+
build-type: Simple
5+
6+
library
7+
exposed-modules: Dependency
8+
default-language: Haskell2010
9+
build-depends: base
10+
, containers
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cradle:
2+
cabal:

ghcide/test/exe/Dependency.hs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tests =
3636
, dependencyTypeTest
3737
, transitiveDependencyTest
3838
, autogenDependencyTest
39+
, bootDependencyTest
3940
]
4041

4142
fileDoneIndexing :: [String] -> Session FilePath
@@ -202,3 +203,35 @@ autogenDependencyTest = knownBrokenForGhcVersions [GHC810, GHC90] "stylish-haske
202203
liftIO $
203204
assertFailure $ "Wrong location for version: "
204205
++ show wrongLocation
206+
207+
-- Tests that we can go to a definition in a boot library, that is,
208+
-- one of the libraries that ships with GHC. In this case we are
209+
-- going to a definition in containers. This does not currently work
210+
-- for available GHC versions but hopefully will for later versions
211+
-- of GHC.
212+
bootDependencyTest :: TestTree
213+
bootDependencyTest = knownBrokenForGhcVersions [GHC810, GHC90, GHC92, GHC94, GHC96] "HIE files are not generated by older GHCs" $
214+
testSessionWithExtraFiles "dependency-boot" "gotoDefinition term in boot library containers" $
215+
\dir -> do
216+
doc <- openDoc (dir </> "Dependency" <.> "hs") "haskell"
217+
_hieFile <- fileDoneIndexing ["Data", "Set", "Internal.hie"]
218+
defs <- getDefinitions doc (Position 5 20)
219+
-- The location of the definition of empty in Data.Set.Internal.
220+
-- This will likely need to be updated when there is a GHC for
221+
-- which this test can pass.
222+
let expRange = Range (Position 513 0) (Position 513 11)
223+
case defs of
224+
InL (Definition (InR [Location fp actualRange])) ->
225+
liftIO $ do
226+
let locationDirectories :: [String]
227+
locationDirectories =
228+
maybe [] splitDirectories $
229+
uriToFilePath fp
230+
assertBool "empty found in a module that is not Data.Set.Internal"
231+
$ ["Data", "Set", "Internal.hs"]
232+
`isSuffixOf` locationDirectories
233+
actualRange @?= expRange
234+
wrongLocation ->
235+
liftIO $
236+
assertFailure $ "Wrong location for empty: "
237+
++ show wrongLocation

0 commit comments

Comments
 (0)