Skip to content

Commit 9902ab7

Browse files
committed
Use minimal package for autogen dependency test
1 parent c23139d commit 9902ab7

File tree

4 files changed

+20
-37
lines changed

4 files changed

+20
-37
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Dependency where
22

3-
import Language.Haskell.Stylish (Step, tabs)
3+
import Data.Version (Version)
4+
import Paths_minimal_autogen (version)
45

5-
t :: Int -> Step
6-
t = tabs
6+
v :: Version
7+
v = version
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
packages: .
22
package *
33
ghc-options: -fwrite-ide-info
4+
source-repository-package
5+
type:git
6+
location: https://github.com/nlander/minimal-autogen.git
7+
tag: 1c6a440fa213185a34ebd5a0b1870e5e73f03c10

ghcide/test/data/dependency-autogen/dependency-autogen.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ library
77
exposed-modules: Dependency
88
default-language: Haskell2010
99
build-depends: base
10-
, stylish-haskell == 0.14.5.0
10+
, minimal-autogen

ghcide/test/exe/Dependency.hs

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -156,50 +156,28 @@ transitiveDependencyTest = testSessionWithExtraFiles "dependency" "goto transiti
156156
++ show wrongLocation
157157

158158
-- Testing that we can go to a definition in an autogen module of a
159-
-- dependency. Stylish haskell is a package that has an autogen module,
160-
-- but it doesn't seem to build with ghc 9.0 or earlier. Suggestions on
161-
-- another package we could use for this test are welcome! This test
162-
-- doesn't go directly to the fuction in the autogen module because
163-
-- it is a hidden module, so we can't import that function directly
164-
-- in our project. However, hidden modules are also indexed, so we
165-
-- can go to a definition in a module that imports the autogen module
166-
-- and goto the autogen module from there.
159+
-- dependency. We use the repository https://github.com/nlander/minimal-autogen.git
160+
-- as the dependency. It is a minimal package with an autogen module,
161+
-- allowing us to avoid building a larger dependency in CI just for
162+
-- this test.
167163
autogenDependencyTest :: TestTree
168-
autogenDependencyTest = knownBrokenForGhcVersions [GHC810, GHC90] "stylish-haskell does not build with older GHC versions" $
169-
testSessionWithExtraFiles "dependency-autogen" "goto autogen module in dependency" $
164+
autogenDependencyTest = testSessionWithExtraFiles "dependency-autogen" "goto autogen module in dependency" $
170165
\dir -> do
171166
localDoc <- openDoc (dir </> "Dependency" <.> "hs") "haskell"
172-
_hieFile <- fileDoneIndexing ["Paths_stylish_haskell.hie"]
173-
stylishDefs <- getDefinitions localDoc (Position 5 5)
174-
stylishFile <- case stylishDefs of
175-
InL (Definition (InR [Location uri _actualRange])) ->
176-
liftIO $ do
177-
let fp :: FilePath
178-
fp = fromMaybe "" $ uriToFilePath uri
179-
locationDirectories :: [String]
180-
locationDirectories = splitDirectories fp
181-
assertBool "tags found in a module that is not Language.Haskell.Stylish"
182-
$ ["Language", "Haskell", "Stylish.hs"]
183-
`isSuffixOf` locationDirectories
184-
pure fp
185-
wrongLocation ->
186-
liftIO $
187-
assertFailure $ "Wrong location for AsyncCancelled: "
188-
++ show wrongLocation
189-
stylishDoc <- openDoc stylishFile "haskell"
190-
pathsDefs <- getDefinitions stylishDoc (Position 19 8)
167+
_hieFile <- fileDoneIndexing ["Paths_minimal_autogen.hie"]
168+
defs <- getDefinitions localDoc (Position 6 5)
191169
-- The location of the definition of version in
192-
-- Paths_stylish_haskell
170+
-- Paths_minimal_autogen
193171
let expRange = Range (Position 35 0) (Position 35 7)
194-
case pathsDefs of
172+
case defs of
195173
InL (Definition (InR [Location uri actualRange])) ->
196174
liftIO $ do
197175
let locationDirectories :: [String]
198176
locationDirectories =
199177
maybe [] splitDirectories $
200178
uriToFilePath uri
201-
assertBool "version found in a module that is not Paths_stylish_haskell"
202-
$ ["Paths_stylish_haskell.hs"]
179+
assertBool "version found in a module that is not Paths_minimal_autogen"
180+
$ ["Paths_minimal_autogen.hs"]
203181
`isSuffixOf` locationDirectories
204182
actualRange @?= expRange
205183
wrongLocation ->

0 commit comments

Comments
 (0)