Skip to content

Commit 3f9cf44

Browse files
committed
Move dependencyTest to top level
1 parent d0c18d3 commit 3f9cf44

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

ghcide/test/exe/Dependency.hs

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,42 @@ tests =
3232
testGroup "gotoDefinition for dependencies"
3333
[ dependencyTest
3434
]
35+
36+
fileDoneIndexing :: [String] -> Session FilePath
37+
fileDoneIndexing fpSuffix =
38+
skipManyTill anyMessage indexedFile
3539
where
36-
dependencyTest :: TestTree
37-
dependencyTest = testSessionWithExtraFiles "dependency" "gotoDefinition in async" $
38-
\dir -> do
39-
doc <- openDoc (dir </> "Dependency" <.> "hs") "haskell"
40-
_hieFile <- fileDoneIndexing ["Control", "Concurrent", "Async.hie"]
41-
defs <- getDefinitions doc (Position 5 20)
42-
let expRange = Range (Position 430 22) (Position 430 36)
43-
case defs of
44-
InL (Definition (InR [Location fp actualRange])) ->
45-
liftIO $ do
46-
let locationDirectories :: [String]
47-
locationDirectories =
48-
maybe [] splitDirectories $
49-
uriToFilePath fp
50-
assertBool "AsyncCancelled found in a module that is not Control.Concurrent Async"
51-
$ ["Control", "Concurrent", "Async.hs"]
52-
`isSuffixOf` locationDirectories
53-
actualRange @?= expRange
54-
wrongLocation ->
55-
liftIO $
56-
assertFailure $ "Wrong location for AsyncCancelled: "
57-
++ show wrongLocation
58-
fileDoneIndexing :: [String] -> Session FilePath
59-
fileDoneIndexing fpSuffix =
60-
skipManyTill anyMessage indexedFile
61-
where
62-
indexedFile :: Session FilePath
63-
indexedFile = do
64-
NotMess TNotificationMessage{_params} <-
65-
customNotification (Proxy @"ghcide/reference/ready")
66-
case A.fromJSON _params of
67-
A.Success fp -> do
68-
let fpDirs :: [String]
69-
fpDirs = splitDirectories fp
70-
bool Applicative.empty (pure fp) $
71-
fpSuffix `isSuffixOf` fpDirs
72-
other -> error $ "Failed to parse ghcide/reference/ready file: " <> show other
40+
indexedFile :: Session FilePath
41+
indexedFile = do
42+
NotMess TNotificationMessage{_params} <-
43+
customNotification (Proxy @"ghcide/reference/ready")
44+
case A.fromJSON _params of
45+
A.Success fp -> do
46+
let fpDirs :: [String]
47+
fpDirs = splitDirectories fp
48+
bool Applicative.empty (pure fp) $
49+
fpSuffix `isSuffixOf` fpDirs
50+
other -> error $ "Failed to parse ghcide/reference/ready file: " <> show other
51+
52+
dependencyTest :: TestTree
53+
dependencyTest = testSessionWithExtraFiles "dependency" "gotoDefinition in async" $
54+
\dir -> do
55+
doc <- openDoc (dir </> "Dependency" <.> "hs") "haskell"
56+
_hieFile <- fileDoneIndexing ["Control", "Concurrent", "Async.hie"]
57+
defs <- getDefinitions doc (Position 5 20)
58+
let expRange = Range (Position 430 22) (Position 430 36)
59+
case defs of
60+
InL (Definition (InR [Location fp actualRange])) ->
61+
liftIO $ do
62+
let locationDirectories :: [String]
63+
locationDirectories =
64+
maybe [] splitDirectories $
65+
uriToFilePath fp
66+
assertBool "AsyncCancelled found in a module that is not Control.Concurrent Async"
67+
$ ["Control", "Concurrent", "Async.hs"]
68+
`isSuffixOf` locationDirectories
69+
actualRange @?= expRange
70+
wrongLocation ->
71+
liftIO $
72+
assertFailure $ "Wrong location for AsyncCancelled: "
73+
++ show wrongLocation

0 commit comments

Comments
 (0)