Skip to content

Commit

Permalink
Canonicalize the locations in the cradle tests (haskell/ghcide#628)
Browse files Browse the repository at this point in the history
On macOS, the $TMPDIR folder leads to /var/blahblahblah, but this is
canonicalized to /private/var/blahblahblah for reasons beyond my
understanding. Either way, there were some test failures because of a
mismatch between the two, so canonicalize the Uris inside the locations
to fix this
  • Loading branch information
lukel97 authored Jun 12, 2020
1 parent f0b3953 commit d04cfe9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ghcide/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

0 comments on commit d04cfe9

Please sign in to comment.