Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Canonicalize the locations in the cradle tests #628

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion test/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,10 @@ checkDefs defs mkExpectations = traverse_ check =<< mkExpectations where
assertRangeCorrect (head defs) expectedRange
check (ExpectLocation expectedLocation) = do
assertNDefinitionsFound 1 defs
liftIO $ head defs @?= expectedLocation
liftIO $ do
canonActualLoc <- canonicalizeLocation (head defs)
canonExpectedLoc <- canonicalizeLocation expectedLocation
canonActualLoc @?= canonExpectedLoc
check ExpectNoDefinitions = do
assertNDefinitionsFound 0 defs
check ExpectExternFail = liftIO $ assertFailure "Expecting to fail to find in external file"
Expand All @@ -1321,6 +1324,10 @@ checkDefs defs mkExpectations = traverse_ check =<< mkExpectations where
assertRangeCorrect Location{_range = foundRange} expectedRange =
liftIO $ expectedRange @=? foundRange

canonicalizeLocation :: Location -> IO Location
canonicalizeLocation (Location uri range) = Location <$> canonUri uri <*> pure range
where
canonUri uri = filePathToUri <$> canonicalizePath (fromJust (uriToFilePath uri))

findDefinitionAndHoverTests :: TestTree
findDefinitionAndHoverTests = let
Expand Down