From ed67c9d2cc00c401fdc0360e89b719ace929b8ee Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 11 Jun 2020 14:36:12 +0100 Subject: [PATCH] Canonicalize the locations in the cradle tests 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 --- test/exe/Main.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/exe/Main.hs b/test/exe/Main.hs index ba4cd3590..39e0c37d8 100644 --- a/test/exe/Main.hs +++ b/test/exe/Main.hs @@ -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" @@ -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