Skip to content

Commit 14e30e4

Browse files
authored
Canonicalize the locations in the cradle tests (#628)
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
1 parent d4054ef commit 14e30e4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/exe/Main.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,10 @@ checkDefs defs mkExpectations = traverse_ check =<< mkExpectations where
13091309
assertRangeCorrect (head defs) expectedRange
13101310
check (ExpectLocation expectedLocation) = do
13111311
assertNDefinitionsFound 1 defs
1312-
liftIO $ head defs @?= expectedLocation
1312+
liftIO $ do
1313+
canonActualLoc <- canonicalizeLocation (head defs)
1314+
canonExpectedLoc <- canonicalizeLocation expectedLocation
1315+
canonActualLoc @?= canonExpectedLoc
13131316
check ExpectNoDefinitions = do
13141317
assertNDefinitionsFound 0 defs
13151318
check ExpectExternFail = liftIO $ assertFailure "Expecting to fail to find in external file"
@@ -1321,6 +1324,10 @@ checkDefs defs mkExpectations = traverse_ check =<< mkExpectations where
13211324
assertRangeCorrect Location{_range = foundRange} expectedRange =
13221325
liftIO $ expectedRange @=? foundRange
13231326

1327+
canonicalizeLocation :: Location -> IO Location
1328+
canonicalizeLocation (Location uri range) = Location <$> canonUri uri <*> pure range
1329+
where
1330+
canonUri uri = filePathToUri <$> canonicalizePath (fromJust (uriToFilePath uri))
13241331

13251332
findDefinitionAndHoverTests :: TestTree
13261333
findDefinitionAndHoverTests = let

0 commit comments

Comments
 (0)