@@ -2210,6 +2210,77 @@ final class BackgroundIndexingTests: XCTestCase {
22102210      } 
22112211    ) 
22122212  } 
2213+ 
2214+   func  testBuildSystemUsesStandardizedFileUrlsInsteadOfRealpath( )  async  throws  { 
2215+     try   SkipUnless . platformIsDarwin ( " The realpath vs standardized path difference only exists on macOS " ) 
2216+ 
2217+     final  class  BuildSystem :  CustomBuildServer  { 
2218+       let  inProgressRequestsTracker   =  CustomBuildServerInProgressRequestTracker ( ) 
2219+       private  let  projectRoot :  URL 
2220+       private  var  testFileURL :  URL  {  projectRoot. appendingPathComponent ( " test.c " ) . standardized } 
2221+ 
2222+       required   init ( projectRoot:  URL ,  connectionToSourceKitLSP:  any  LanguageServerProtocol . Connection )  { 
2223+         self . projectRoot =  projectRoot
2224+       } 
2225+ 
2226+       func  initializeBuildRequest( _ request:  InitializeBuildRequest )  async  throws  ->  InitializeBuildResponse  { 
2227+         return  initializationResponse ( 
2228+           initializeData:  SourceKitInitializeBuildResponseData ( 
2229+             indexDatabasePath:  try   projectRoot. appendingPathComponent ( " index-db " ) . filePath, 
2230+             indexStorePath:  try   projectRoot. appendingPathComponent ( " index-store " ) . filePath, 
2231+             prepareProvider:  true , 
2232+             sourceKitOptionsProvider:  true 
2233+           ) 
2234+         ) 
2235+       } 
2236+ 
2237+       func  buildTargetSourcesRequest( _ request:  BuildTargetSourcesRequest )  async  throws  ->  BuildTargetSourcesResponse  { 
2238+         return  BuildTargetSourcesResponse ( items:  [ 
2239+           SourcesItem ( target:  . dummy,  sources:  [ SourceItem ( uri:  URI ( testFileURL) ,  kind:  . file,  generated:  false ) ] ) 
2240+         ] ) 
2241+       } 
2242+ 
2243+       func  textDocumentSourceKitOptionsRequest( 
2244+         _ request:  TextDocumentSourceKitOptionsRequest 
2245+       )  async  throws  ->  TextDocumentSourceKitOptionsResponse ?   { 
2246+         return  TextDocumentSourceKitOptionsResponse ( compilerArguments:  [ request. textDocument. uri. pseudoPath] ) 
2247+       } 
2248+     } 
2249+ 
2250+     let  scratchDirectory  =  URL ( fileURLWithPath:  " /tmp " ) 
2251+       . appendingPathComponent ( " sourcekitlsp-test " ) 
2252+       . appendingPathComponent ( testScratchName ( ) ) 
2253+     let  indexedFiles  =  ThreadSafeBox < [ DocumentURI ] > ( initialValue:  [ ] ) 
2254+     let  project  =  try   await  CustomBuildServerTestProject ( 
2255+       files:  [ 
2256+         " test.c " :  " void x() {} " 
2257+       ] , 
2258+       buildServer:  BuildSystem . self, 
2259+       hooks:  Hooks ( 
2260+         indexHooks:  IndexHooks ( 
2261+           updateIndexStoreTaskDidStart:  {  task in 
2262+             indexedFiles. withLock  {  indexedFiles in 
2263+               indexedFiles +=  task. filesToIndex. map ( \. file. sourceFile) 
2264+             } 
2265+           } 
2266+         ) 
2267+       ) , 
2268+       enableBackgroundIndexing:  true , 
2269+       testScratchDir:  scratchDirectory
2270+     ) 
2271+     try   await  project. testClient. send ( PollIndexRequest ( ) ) 
2272+ 
2273+     // Ensure that changing `/private/tmp/.../test.c` only causes `/tmp/.../test.c` to be indexed, not
2274+     // `/private/tmp/.../test.c`.
2275+     indexedFiles. value =  [ ] 
2276+     let  testFileURL  =  try   XCTUnwrap ( project. uri ( for:  " test.c " ) . fileURL? . realpath) 
2277+     try   await  " void y() {} " . writeWithRetry ( to:  testFileURL) 
2278+     project. testClient. send ( 
2279+       DidChangeWatchedFilesNotification ( changes:  [ FileEvent ( uri:  DocumentURI ( testFileURL) ,  type:  . changed) ] ) 
2280+     ) 
2281+     try   await  project. testClient. send ( PollIndexRequest ( ) ) 
2282+     XCTAssertEqual ( indexedFiles. value,  [ try   project. uri ( for:  " test.c " ) ] ) 
2283+   } 
22132284} 
22142285
22152286extension  HoverResponseContents  { 
0 commit comments