From a2bf9549fa85034b3b5f1d1cbdba38f9a6e95cac Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Fri, 15 Nov 2024 22:50:57 -0800 Subject: [PATCH] Restrict directories that we search for `MyDependency.swift` in tests It appears that moving the index-build directory to be a subdirectory of `.build` caused some file in the index-build directory to exceed the `MAX_PATH` length on the SourceKit-LSP PR testing job (but not the swift PR job because that has a shorter job name). Because of https://github.com/swiftlang/swift-foundation/issues/1049, we would stop directory iteration at that file exceeding `MAX_PATH` and never find `MyDependency.swift`, causing these tests to fail. --- .../BackgroundIndexingTests.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift b/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift index 9aec90aac..442ac5ec6 100644 --- a/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift +++ b/Tests/SourceKitLSPTests/BackgroundIndexingTests.swift @@ -245,7 +245,11 @@ final class BackgroundIndexingTests: XCTestCase { ) let dependencyUrl = try XCTUnwrap( - FileManager.default.findFiles(named: "MyDependency.swift", in: project.scratchDirectory).only + FileManager.default.findFiles( + named: "MyDependency.swift", + in: project.scratchDirectory.appendingPathComponent(".build").appendingPathComponent("index-build") + .appendingPathComponent("checkouts") + ).only ) let dependencyUri = DocumentURI(dependencyUrl) let testFileUri = try project.uri(for: "Test.swift") @@ -1256,9 +1260,11 @@ final class BackgroundIndexingTests: XCTestCase { try await project.testClient.send(PollIndexRequest()) project.testClient.send( DidChangeWatchedFilesNotification( - changes: FileManager.default.findFiles(named: "Dependency.swift", in: project.scratchDirectory).map { - FileEvent(uri: DocumentURI($0), type: .changed) - } + changes: FileManager.default.findFiles( + named: "Dependency.swift", + in: project.scratchDirectory.appendingPathComponent(".build").appendingPathComponent("index-build") + .appendingPathComponent("checkouts") + ).map { FileEvent(uri: DocumentURI($0), type: .changed) } ) )