diff --git a/Sources/SKTestSupport/IndexedSingleSwiftFileWorkspace.swift b/Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift similarity index 98% rename from Sources/SKTestSupport/IndexedSingleSwiftFileWorkspace.swift rename to Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift index 10a4a074..762233ae 100644 --- a/Sources/SKTestSupport/IndexedSingleSwiftFileWorkspace.swift +++ b/Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift @@ -17,7 +17,7 @@ import LanguageServerProtocol import SourceKitLSP import TSCBasic -public struct IndexedSingleSwiftFileWorkspace { +public struct IndexedSingleSwiftFileTestProject { enum Error: Swift.Error { case swiftcNotFound } diff --git a/Sources/SKTestSupport/MultiFileTestWorkspace.swift b/Sources/SKTestSupport/MultiFileTestProject.swift similarity index 94% rename from Sources/SKTestSupport/MultiFileTestWorkspace.swift rename to Sources/SKTestSupport/MultiFileTestProject.swift index 405e2eb3..3eec7f45 100644 --- a/Sources/SKTestSupport/MultiFileTestWorkspace.swift +++ b/Sources/SKTestSupport/MultiFileTestProject.swift @@ -33,11 +33,11 @@ public struct RelativeFileLocation: Hashable, ExpressibleByStringLiteral { } } -/// A workspace that writes multiple files to disk and opens a `TestSourceKitLSPClient` client with a workspace pointing -/// to a temporary directory containing those files. +/// A test project that writes multiple files to disk and opens a `TestSourceKitLSPClient` client with a workspace +/// pointing to a temporary directory containing those files. /// /// The temporary files will be deleted when the `TestSourceKitLSPClient` is destructed. -public class MultiFileTestWorkspace { +public class MultiFileTestProject { /// Information necessary to open a file in the LSP server by its filename. private struct FileData { /// The URI at which the file is stored on disk. @@ -53,7 +53,7 @@ public class MultiFileTestWorkspace { private let fileData: [String: FileData] enum Error: Swift.Error { - /// No file with the given filename is known to the `SwiftPMTestWorkspace`. + /// No file with the given filename is known to the `MultiFileTestProject`. case fileNotFound } diff --git a/Sources/SKTestSupport/SkipUnless.swift b/Sources/SKTestSupport/SkipUnless.swift index 0b85f052..3a6ceedd 100644 --- a/Sources/SKTestSupport/SkipUnless.swift +++ b/Sources/SKTestSupport/SkipUnless.swift @@ -180,7 +180,7 @@ public enum SkipUnless { line: UInt = #line ) async throws { try await skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(5, 11), file: file, line: line) { - let workspace = try await SwiftPMTestWorkspace( + let workspace = try await SwiftPMTestProject( files: ["test.swift": ""], build: true ) diff --git a/Sources/SKTestSupport/SwiftPMTestWorkspace.swift b/Sources/SKTestSupport/SwiftPMTestProject.swift similarity index 96% rename from Sources/SKTestSupport/SwiftPMTestWorkspace.swift rename to Sources/SKTestSupport/SwiftPMTestProject.swift index 33e91c5c..16c64e6f 100644 --- a/Sources/SKTestSupport/SwiftPMTestWorkspace.swift +++ b/Sources/SKTestSupport/SwiftPMTestProject.swift @@ -15,7 +15,7 @@ import LanguageServerProtocol @_spi(Testing) import SKCore import TSCBasic -public class SwiftPMTestWorkspace: MultiFileTestWorkspace { +public class SwiftPMTestProject: MultiFileTestProject { enum Error: Swift.Error { /// The `swift` executable could not be found. case swiftNotFound @@ -37,7 +37,7 @@ public class SwiftPMTestWorkspace: MultiFileTestWorkspace { /// If `index` is `true`, then the package will be built, indexing all modules within the package. public init( files: [RelativeFileLocation: String], - manifest: String = SwiftPMTestWorkspace.defaultPackageManifest, + manifest: String = SwiftPMTestProject.defaultPackageManifest, workspaces: (URL) -> [WorkspaceFolder] = { [WorkspaceFolder(uri: DocumentURI($0))] }, build: Bool = false, usePullDiagnostics: Bool = true, diff --git a/Sources/SKTestSupport/TestSourceKitLSPClient.swift b/Sources/SKTestSupport/TestSourceKitLSPClient.swift index 200efe8f..d3ce5209 100644 --- a/Sources/SKTestSupport/TestSourceKitLSPClient.swift +++ b/Sources/SKTestSupport/TestSourceKitLSPClient.swift @@ -70,7 +70,7 @@ public final class TestSourceKitLSPClient: MessageHandler { /// A closure that is called when the `TestSourceKitLSPClient` is destructed. /// - /// This allows e.g. a `IndexedSingleSwiftFileWorkspace` to delete its temporary files when they are no longer needed. + /// This allows e.g. a `IndexedSingleSwiftFileTestProject` to delete its temporary files when they are no longer needed. private let cleanUp: () -> Void /// - Parameters: @@ -84,7 +84,7 @@ public final class TestSourceKitLSPClient: MessageHandler { /// - usePullDiagnostics: Whether to use push diagnostics or use push-based diagnostics /// - workspaceFolders: Workspace folders to open. /// - cleanUp: A closure that is called when the `TestSourceKitLSPClient` is destructed. - /// This allows e.g. a `IndexedSingleSwiftFileWorkspace` to delete its temporary files when they are no longer + /// This allows e.g. a `IndexedSingleSwiftFileTestProject` to delete its temporary files when they are no longer /// needed. public init( serverOptions: SourceKitLSPServer.Options = .testDefault, diff --git a/Tests/SourceKitDTests/CrashRecoveryTests.swift b/Tests/SourceKitDTests/CrashRecoveryTests.swift index 48b8469b..c1b4121e 100644 --- a/Tests/SourceKitDTests/CrashRecoveryTests.swift +++ b/Tests/SourceKitDTests/CrashRecoveryTests.swift @@ -202,7 +202,7 @@ final class CrashRecoveryTests: XCTestCase { func testClangdCrashRecoveryReopensWithCorrectBuildSettings() async throws { try SkipUnless.longTestsEnabled() - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "main.cpp": """ #if FOO void 1️⃣foo2️⃣() {} diff --git a/Tests/SourceKitLSPTests/CallHierarchyTests.swift b/Tests/SourceKitLSPTests/CallHierarchyTests.swift index 340cc365..daa0d337 100644 --- a/Tests/SourceKitLSPTests/CallHierarchyTests.swift +++ b/Tests/SourceKitLSPTests/CallHierarchyTests.swift @@ -19,7 +19,7 @@ import XCTest final class CallHierarchyTests: XCTestCase { func testCallHierarchy() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ func 1️⃣a() {} @@ -185,7 +185,7 @@ final class CallHierarchyTests: XCTestCase { } func testReportSingleItemInPrepareCallHierarchy() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "MyLibrary/include/lib.h": """ struct FilePathIndex { @@ -227,7 +227,7 @@ final class CallHierarchyTests: XCTestCase { func testIncomingCallHierarchyShowsSurroundingFunctionCall() async throws { // We used to show `myVar` as the caller here - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ func 1️⃣foo() {} @@ -268,7 +268,7 @@ final class CallHierarchyTests: XCTestCase { } func testIncomingCallHierarchyFromComputedProperty() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ func 1️⃣foo() {} @@ -310,7 +310,7 @@ final class CallHierarchyTests: XCTestCase { } func testIncomingCallHierarchyShowsAccessToVariables() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ var 1️⃣foo: Int func 2️⃣testFunc() { @@ -368,7 +368,7 @@ final class CallHierarchyTests: XCTestCase { } func testOutgoingCallHierarchyShowsAccessesToVariable() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ var 1️⃣foo: Int func 2️⃣testFunc() { @@ -409,7 +409,7 @@ final class CallHierarchyTests: XCTestCase { } func testOutgoingCallHierarchyFromVariableAccessor() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ func 1️⃣testFunc() -> Int { 0 } var 2️⃣foo: Int { @@ -449,7 +449,7 @@ final class CallHierarchyTests: XCTestCase { } func testIncomingCallHierarchyLooksThroughProtocols() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ protocol MyProtocol { func foo() @@ -498,7 +498,7 @@ final class CallHierarchyTests: XCTestCase { } func testIncomingCallHierarchyLooksThroughSuperclasses() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ class Base { func foo() {} diff --git a/Tests/SourceKitLSPTests/ClangdTests.swift b/Tests/SourceKitLSPTests/ClangdTests.swift index c9f6ea0b..e4edd59f 100644 --- a/Tests/SourceKitLSPTests/ClangdTests.swift +++ b/Tests/SourceKitLSPTests/ClangdTests.swift @@ -16,7 +16,7 @@ import XCTest final class ClangdTests: XCTestCase { func testClangdGoToInclude() async throws { - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "Object.h": "", "main.c": """ #include 1️⃣"Object.h" @@ -47,7 +47,7 @@ final class ClangdTests: XCTestCase { } func testClangdGoToDefinitionWithoutIndex() async throws { - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "Object.h": """ struct Object { int field; @@ -87,7 +87,7 @@ final class ClangdTests: XCTestCase { } func testClangdGoToDeclaration() async throws { - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "Object.h": """ struct Object { int field; diff --git a/Tests/SourceKitLSPTests/CodeActionTests.swift b/Tests/SourceKitLSPTests/CodeActionTests.swift index 42dcd9f9..4e3f9b06 100644 --- a/Tests/SourceKitLSPTests/CodeActionTests.swift +++ b/Tests/SourceKitLSPTests/CodeActionTests.swift @@ -430,7 +430,7 @@ final class CodeActionTests: XCTestCase { } func testCodeActionForFixItsProducedBySwiftSyntax() async throws { - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "test.swift": "protocol 1️⃣Multi 2️⃣ident 3️⃣{}", "compile_commands.json": "[]", ]) diff --git a/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift b/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift index 1e2696a7..949ee9f1 100644 --- a/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift +++ b/Tests/SourceKitLSPTests/CompilationDatabaseTests.swift @@ -19,7 +19,7 @@ import XCTest final class CompilationDatabaseTests: XCTestCase { func testModifyCompilationDatabase() async throws { - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "main.cpp": """ #if FOO void 1️⃣foo2️⃣() {} diff --git a/Tests/SourceKitLSPTests/DefinitionTests.swift b/Tests/SourceKitLSPTests/DefinitionTests.swift index 36c360d6..9c5a00e6 100644 --- a/Tests/SourceKitLSPTests/DefinitionTests.swift +++ b/Tests/SourceKitLSPTests/DefinitionTests.swift @@ -40,7 +40,7 @@ class DefinitionTests: XCTestCase { } func testJumpToDefinitionIncludesOverrides() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ protocol TestProtocol { func 1️⃣doThing() @@ -73,7 +73,7 @@ class DefinitionTests: XCTestCase { } func testJumpToDefinitionFiltersByReceiver() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ class A { func 1️⃣doThing() {} @@ -109,7 +109,7 @@ class DefinitionTests: XCTestCase { } func testDynamicJumpToDefinitionInClang() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Sources/MyLibrary/include/dummy.h": "", "test.cpp": """ @@ -147,7 +147,7 @@ class DefinitionTests: XCTestCase { } func testJumpToCDefinitionFromSwift() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Sources/MyLibrary/include/test.h": """ void myFunc(void); @@ -226,7 +226,7 @@ class DefinitionTests: XCTestCase { func testAmbiguousDefinition() async throws { // FIXME: This shouldn't have to be an indexed workspace but solver-based cursor info currently fails if the file // does not exist on disk. - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ func 1️⃣foo() -> Int { 1 } func 2️⃣foo() -> String { "" } @@ -251,7 +251,7 @@ class DefinitionTests: XCTestCase { func testDefinitionOfClassBetweenModulesObjC() async throws { try SkipUnless.platformIsDarwin("@import in Objective-C is not enabled on non-Darwin") - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "LibA/include/LibA.h": """ @interface 1️⃣LibAClass2️⃣ @@ -308,7 +308,7 @@ class DefinitionTests: XCTestCase { func testDefinitionOfMethodBetweenModulesObjC() async throws { try SkipUnless.platformIsDarwin("@import in Objective-C is not enabled on non-Darwin") - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "LibA/include/LibA.h": """ @interface LibAClass diff --git a/Tests/SourceKitLSPTests/DependencyTrackingTests.swift b/Tests/SourceKitLSPTests/DependencyTrackingTests.swift index 78ce41d6..ddf710fa 100644 --- a/Tests/SourceKitLSPTests/DependencyTrackingTests.swift +++ b/Tests/SourceKitLSPTests/DependencyTrackingTests.swift @@ -17,7 +17,7 @@ import XCTest final class DependencyTrackingTests: XCTestCase { func testDependenciesUpdatedSwift() async throws { try await SkipUnless.swiftpmStoresModulesInSubdirectory() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "LibA/LibA.swift": """ public func aaa() {} @@ -60,7 +60,7 @@ final class DependencyTrackingTests: XCTestCase { ) } - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory) + try await SwiftPMTestProject.build(at: ws.scratchDirectory) await ws.testClient.server.filesDependenciesUpdated([libBUri]) @@ -70,7 +70,7 @@ final class DependencyTrackingTests: XCTestCase { } func testDependenciesUpdatedCXX() async throws { - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "lib.c": """ int libX(int value) { diff --git a/Tests/SourceKitLSPTests/FormattingTests.swift b/Tests/SourceKitLSPTests/FormattingTests.swift index 52b847d1..2b5b860a 100644 --- a/Tests/SourceKitLSPTests/FormattingTests.swift +++ b/Tests/SourceKitLSPTests/FormattingTests.swift @@ -81,7 +81,7 @@ final class FormattingTests: XCTestCase { func testConfigFileOnDisk() async throws { try await SkipUnless.toolchainContainsSwiftFormat() // We pick up an invalid swift-format configuration file and thus don't set the user-provided options. - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ ".swift-format": """ { "version": 1, @@ -116,7 +116,7 @@ final class FormattingTests: XCTestCase { func testConfigFileInParentDirectory() async throws { try await SkipUnless.toolchainContainsSwiftFormat() // We pick up an invalid swift-format configuration file and thus don't set the user-provided options. - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ ".swift-format": """ { "version": 1, @@ -151,7 +151,7 @@ final class FormattingTests: XCTestCase { func testConfigFileInNestedDirectory() async throws { try await SkipUnless.toolchainContainsSwiftFormat() // We pick up an invalid swift-format configuration file and thus don't set the user-provided options. - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ ".swift-format": """ { "version": 1, @@ -195,7 +195,7 @@ final class FormattingTests: XCTestCase { try await SkipUnless.toolchainContainsSwiftFormat() // We pick up an invalid swift-format configuration file and thus don't set the user-provided options. // The swift-format default is 2 spaces. - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ ".swift-format": "", "test.swift": """ struct Root { diff --git a/Tests/SourceKitLSPTests/ImplementationTests.swift b/Tests/SourceKitLSPTests/ImplementationTests.swift index b3303af3..60e25e0b 100644 --- a/Tests/SourceKitLSPTests/ImplementationTests.swift +++ b/Tests/SourceKitLSPTests/ImplementationTests.swift @@ -26,7 +26,7 @@ final class ImplementationTests: XCTestCase { testName: String = #function, line: UInt = #line ) async throws { - let ws = try await IndexedSingleSwiftFileWorkspace(markedText, testName: testName) + let ws = try await IndexedSingleSwiftFileTestProject(markedText, testName: testName) let response = try await ws.testClient.send( ImplementationRequest( textDocument: TextDocumentIdentifier(ws.fileURI), @@ -287,7 +287,7 @@ final class ImplementationTests: XCTestCase { } func testCrossFile() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "a.swift": """ protocol 1️⃣MyProto {} diff --git a/Tests/SourceKitLSPTests/IndexTests.swift b/Tests/SourceKitLSPTests/IndexTests.swift index 9424d9f3..89bbde60 100644 --- a/Tests/SourceKitLSPTests/IndexTests.swift +++ b/Tests/SourceKitLSPTests/IndexTests.swift @@ -17,7 +17,7 @@ import XCTest final class IndexTests: XCTestCase { func testIndexSwiftModules() async throws { try await SkipUnless.swiftpmStoresModulesInSubdirectory() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "LibA/LibA.swift": """ public func 1️⃣aaa() {} @@ -113,7 +113,7 @@ final class IndexTests: XCTestCase { } func checkRunningIndex(cleanUp: Bool, workspaceDirectory: URL) async throws -> URL? { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ func 1️⃣foo() {} diff --git a/Tests/SourceKitLSPTests/LocalClangTests.swift b/Tests/SourceKitLSPTests/LocalClangTests.swift index 2caba182..374fad07 100644 --- a/Tests/SourceKitLSPTests/LocalClangTests.swift +++ b/Tests/SourceKitLSPTests/LocalClangTests.swift @@ -220,7 +220,7 @@ final class LocalClangTests: XCTestCase { // Note: tests generally should avoid including system headers // to keep them fast and portable. This test is specifically // ensuring clangd can find libc++ and builtin headers. - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "main.cpp": """ #include @@ -246,7 +246,7 @@ final class LocalClangTests: XCTestCase { } func testClangModules() async throws { - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "ClangModuleA.h": """ #ifndef ClangModuleA_h @@ -304,7 +304,7 @@ final class LocalClangTests: XCTestCase { } func testDocumentDependenciesUpdated() async throws { - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "Object.h": """ struct Object { diff --git a/Tests/SourceKitLSPTests/MainFilesProviderTests.swift b/Tests/SourceKitLSPTests/MainFilesProviderTests.swift index 61a7fb38..1cc883e3 100644 --- a/Tests/SourceKitLSPTests/MainFilesProviderTests.swift +++ b/Tests/SourceKitLSPTests/MainFilesProviderTests.swift @@ -20,7 +20,7 @@ import XCTest final class MainFilesProviderTests: XCTestCase { func testMainFileForHeaderInPackageTarget() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "MyLibrary/include/MyLibrary.h": """ void bridging(void) { @@ -60,7 +60,7 @@ final class MainFilesProviderTests: XCTestCase { } func testMainFileForHeaderOutsideOfTarget() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Sources/shared.h": """ void bridging(void) { @@ -98,7 +98,7 @@ final class MainFilesProviderTests: XCTestCase { let preBuildDiags = try await ws.testClient.nextDiagnosticsNotification() XCTAssertEqual(preBuildDiags.diagnostics.count, 0) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory) + try await SwiftPMTestProject.build(at: ws.scratchDirectory) // After building we know that 'shared.h' is included from 'MyLibrary.c' and thus we use its build settings, // defining `VARIABLE_NAME` to `fromMyLibrary`. @@ -109,7 +109,7 @@ final class MainFilesProviderTests: XCTestCase { } func testMainFileForSharedHeaderOutsideOfTarget() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Sources/shared.h": """ void bridging(void) { @@ -160,7 +160,7 @@ final class MainFilesProviderTests: XCTestCase { } func testMainFileChangesIfIncludeIsAdded() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Sources/shared.h": """ void bridging(void) { @@ -212,7 +212,7 @@ final class MainFilesProviderTests: XCTestCase { let fancyLibraryURL = try ws.uri(for: "MyFancyLibrary.c").fileURL! try newFancyLibraryContents.write(to: fancyLibraryURL, atomically: false, encoding: .utf8) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory) + try await SwiftPMTestProject.build(at: ws.scratchDirectory) // 'MyFancyLibrary.c' now also includes 'shared.h'. Since it lexicographically preceeds MyLibrary, we should use its // build settings. diff --git a/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift b/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift index 7df905d6..1f00ff3b 100644 --- a/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift +++ b/Tests/SourceKitLSPTests/PullDiagnosticsTests.swift @@ -110,7 +110,7 @@ final class PullDiagnosticsTests: XCTestCase { func testNotesFromIntegratedSwiftSyntaxDiagnostics() async throws { // Create a workspace that has compile_commands.json so that it has a build system but no compiler arguments // for test.swift so that we fall back to producing diagnostics from the built-in swift-syntax. - let ws = try await MultiFileTestWorkspace(files: [ + let ws = try await MultiFileTestProject(files: [ "test.swift": "func foo() 1️⃣{2️⃣", "compile_commands.json": "[]", ]) diff --git a/Tests/SourceKitLSPTests/ReferencesTests.swift b/Tests/SourceKitLSPTests/ReferencesTests.swift index 24f444ea..0c378a7b 100644 --- a/Tests/SourceKitLSPTests/ReferencesTests.swift +++ b/Tests/SourceKitLSPTests/ReferencesTests.swift @@ -17,7 +17,7 @@ import XCTest /// Tests that test the overall state of the SourceKit-LSP server, that's not really specific to any language final class ReferencesTests: XCTestCase { func testReferencesInMacro() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ import Observation diff --git a/Tests/SourceKitLSPTests/RenameAssertions.swift b/Tests/SourceKitLSPTests/RenameAssertions.swift index b1662be5..36a77438 100644 --- a/Tests/SourceKitLSPTests/RenameAssertions.swift +++ b/Tests/SourceKitLSPTests/RenameAssertions.swift @@ -83,7 +83,7 @@ func assertRenamedSourceMatches( originalFiles: [RelativeFileLocation: String], changes: [DocumentURI: [TextEdit]], expected: [RelativeFileLocation: String], - in ws: MultiFileTestWorkspace, + in ws: MultiFileTestProject, message: String, testName: String = #function, file: StaticString = #file, @@ -122,14 +122,14 @@ func assertMultiFileRename( newName: String, expectedPrepareRenamePlaceholder: String, expected: [RelativeFileLocation: String], - manifest: String = SwiftPMTestWorkspace.defaultPackageManifest, - preRenameActions: (SwiftPMTestWorkspace) throws -> Void = { _ in }, + manifest: String = SwiftPMTestProject.defaultPackageManifest, + preRenameActions: (SwiftPMTestProject) throws -> Void = { _ in }, testName: String = #function, file: StaticString = #file, line: UInt = #line ) async throws { try await SkipUnless.sourcekitdSupportsRename() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: files, manifest: manifest, build: true, diff --git a/Tests/SourceKitLSPTests/SwiftCompletionTests.swift b/Tests/SourceKitLSPTests/SwiftCompletionTests.swift index bb280a36..2cf4a627 100644 --- a/Tests/SourceKitLSPTests/SwiftCompletionTests.swift +++ b/Tests/SourceKitLSPTests/SwiftCompletionTests.swift @@ -829,7 +829,7 @@ final class SwiftCompletionTests: XCTestCase { } func testCodeCompleteSwiftPackage() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "a.swift": """ struct A { diff --git a/Tests/SourceKitLSPTests/SwiftInterfaceTests.swift b/Tests/SourceKitLSPTests/SwiftInterfaceTests.swift index fe36acb7..4101c86e 100644 --- a/Tests/SourceKitLSPTests/SwiftInterfaceTests.swift +++ b/Tests/SourceKitLSPTests/SwiftInterfaceTests.swift @@ -57,7 +57,7 @@ final class SwiftInterfaceTests: XCTestCase { func testOpenInterface() async throws { try await SkipUnless.swiftpmStoresModulesInSubdirectory() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "MyLibrary/MyLibrary.swift": """ public struct Lib { @@ -141,7 +141,7 @@ final class SwiftInterfaceTests: XCTestCase { } func testDefinitionInSystemModuleInterface() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ public func libFunc() async { let a: 1️⃣String = "test" @@ -185,7 +185,7 @@ final class SwiftInterfaceTests: XCTestCase { func testSwiftInterfaceAcrossModules() async throws { try await SkipUnless.swiftpmStoresModulesInSubdirectory() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "MyLibrary/MyLibrary.swift": """ public struct Lib { diff --git a/Tests/SourceKitLSPTests/SwiftPMIntegration.swift b/Tests/SourceKitLSPTests/SwiftPMIntegration.swift index 126b1a7e..4d38a8fa 100644 --- a/Tests/SourceKitLSPTests/SwiftPMIntegration.swift +++ b/Tests/SourceKitLSPTests/SwiftPMIntegration.swift @@ -18,7 +18,7 @@ import XCTest final class SwiftPMIntegrationTests: XCTestCase { func testSwiftPMIntegration() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Lib.swift": """ struct Lib { @@ -91,7 +91,7 @@ final class SwiftPMIntegrationTests: XCTestCase { } func testAddFile() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Lib.swift": """ struct Lib { diff --git a/Tests/SourceKitLSPTests/TestDiscoveryTests.swift b/Tests/SourceKitLSPTests/TestDiscoveryTests.swift index 26a5ba9e..4c87d058 100644 --- a/Tests/SourceKitLSPTests/TestDiscoveryTests.swift +++ b/Tests/SourceKitLSPTests/TestDiscoveryTests.swift @@ -18,7 +18,7 @@ final class TestDiscoveryTests: XCTestCase { func testWorkspaceTests() async throws { try SkipUnless.longTestsEnabled() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Tests/MyLibraryTests/MyTests.swift": """ import XCTest @@ -75,7 +75,7 @@ final class TestDiscoveryTests: XCTestCase { func testDocumentTests() async throws { try SkipUnless.longTestsEnabled() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Tests/MyLibraryTests/MyTests.swift": """ import XCTest diff --git a/Tests/SourceKitLSPTests/TypeHierarchyTests.swift b/Tests/SourceKitLSPTests/TypeHierarchyTests.swift index 52e7805e..ec7dc4c4 100644 --- a/Tests/SourceKitLSPTests/TypeHierarchyTests.swift +++ b/Tests/SourceKitLSPTests/TypeHierarchyTests.swift @@ -18,7 +18,7 @@ import XCTest final class TypeHierarchyTests: XCTestCase { func testRootClassSupertypes() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ class 1️⃣MyClass {} """ @@ -30,7 +30,7 @@ final class TypeHierarchyTests: XCTestCase { } func testSupertypesOfClass() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ class 1️⃣MyClass {} protocol 2️⃣MyProtocol {} @@ -50,7 +50,7 @@ final class TypeHierarchyTests: XCTestCase { } func testConformedProtocolsOfStruct() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ protocol 1️⃣MyProtocol {} protocol 2️⃣MyOtherProtocol {} @@ -71,7 +71,7 @@ final class TypeHierarchyTests: XCTestCase { } func testSubtypesOfClass() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ class MySuperclass {} class 1️⃣MyClass: MySuperclass {} @@ -92,7 +92,7 @@ final class TypeHierarchyTests: XCTestCase { } func testProtocolConformancesAsSubtypes() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ protocol 1️⃣MyProtocol {} class 2️⃣MyClass: MyProtocol {} @@ -114,7 +114,7 @@ final class TypeHierarchyTests: XCTestCase { } func testExtensionsWithConformancesAsSubtypes() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ protocol MyProtocol {} enum 1️⃣MyEnum {} @@ -143,7 +143,7 @@ final class TypeHierarchyTests: XCTestCase { } func testRetroactiveConformancesAsSubtypes() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ protocol 1️⃣MyProtocol {} struct MyStruct {} @@ -168,7 +168,7 @@ final class TypeHierarchyTests: XCTestCase { } func testSupertypesFromCall() async throws { - let ws = try await IndexedSingleSwiftFileWorkspace( + let ws = try await IndexedSingleSwiftFileTestProject( """ class 1️⃣MyClass {} class MySubclass: MyClass {} @@ -224,7 +224,7 @@ fileprivate extension TypeHierarchyItem { kind: SymbolKind, detail: String = "test", location locationMarker: String, - in ws: IndexedSingleSwiftFileWorkspace + in ws: IndexedSingleSwiftFileTestProject ) { self.init( name: name, @@ -238,7 +238,7 @@ fileprivate extension TypeHierarchyItem { } } -fileprivate extension IndexedSingleSwiftFileWorkspace { +fileprivate extension IndexedSingleSwiftFileTestProject { func prepareTypeHierarchy(at locationMarker: String, line: UInt = #line) async throws -> TypeHierarchyItem { let items = try await testClient.send( TypeHierarchyPrepareRequest( diff --git a/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift b/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift index 6836ef71..d1df571a 100644 --- a/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift +++ b/Tests/SourceKitLSPTests/WorkspaceSymbolsTests.swift @@ -16,7 +16,7 @@ import XCTest class WorkspaceSymbolsTests: XCTestCase { func testWorkspaceSymbolsAcrossPackages() async throws { - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "packageA/Sources/PackageALib/PackageALib.swift": """ public func 1️⃣afuncFromA() {} @@ -63,7 +63,7 @@ class WorkspaceSymbolsTests: XCTestCase { } ) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory.appendingPathComponent("packageB")) + try await SwiftPMTestProject.build(at: ws.scratchDirectory.appendingPathComponent("packageB")) _ = try await ws.testClient.send(PollIndexRequest()) let response = try await ws.testClient.send(WorkspaceSymbolsRequest(query: "funcFrom")) diff --git a/Tests/SourceKitLSPTests/WorkspaceTests.swift b/Tests/SourceKitLSPTests/WorkspaceTests.swift index 414ee0e5..f30d8d42 100644 --- a/Tests/SourceKitLSPTests/WorkspaceTests.swift +++ b/Tests/SourceKitLSPTests/WorkspaceTests.swift @@ -40,7 +40,7 @@ final class WorkspaceTests: XCTestCase { ) """ - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ // PackageA "PackageA/Sources/MyLibrary/libA.swift": """ @@ -79,8 +79,8 @@ final class WorkspaceTests: XCTestCase { } ) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory.appendingPathComponent("PackageA")) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory.appendingPathComponent("PackageB")) + try await SwiftPMTestProject.build(at: ws.scratchDirectory.appendingPathComponent("PackageA")) + try await SwiftPMTestProject.build(at: ws.scratchDirectory.appendingPathComponent("PackageB")) let (bUri, bPositions) = try ws.openDocument("execB.swift") @@ -178,7 +178,7 @@ final class WorkspaceTests: XCTestCase { ) """ - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ // PackageA "PackageA/Sources/MyLibrary/libA.swift": """ @@ -197,7 +197,7 @@ final class WorkspaceTests: XCTestCase { "PackageA/Package.swift": packageManifest, ] ) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory.appendingPathComponent("PackageA")) + try await SwiftPMTestProject.build(at: ws.scratchDirectory.appendingPathComponent("PackageA")) let (uri, positions) = try ws.openDocument("execA.swift") @@ -258,7 +258,7 @@ final class WorkspaceTests: XCTestCase { ) """ - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ // PackageA "PackageA/Sources/MyLibrary/libA.swift": """ @@ -291,8 +291,8 @@ final class WorkspaceTests: XCTestCase { ] ) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory.appendingPathComponent("PackageA")) - try await SwiftPMTestWorkspace.build(at: ws.scratchDirectory) + try await SwiftPMTestProject.build(at: ws.scratchDirectory.appendingPathComponent("PackageA")) + try await SwiftPMTestProject.build(at: ws.scratchDirectory) let (bUri, bPositions) = try ws.openDocument("execB.swift") @@ -374,7 +374,7 @@ final class WorkspaceTests: XCTestCase { } func testMultipleClangdWorkspaces() async throws { - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "WorkspaceA/main.cpp": """ #if FOO @@ -423,10 +423,10 @@ final class WorkspaceTests: XCTestCase { } func testRecomputeFileWorkspaceMembershipOnPackageSwiftChange() async throws { - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "PackageA/Sources/MyLibrary/libA.swift": "", - "PackageA/Package.swift": SwiftPMTestWorkspace.defaultPackageManifest, + "PackageA/Package.swift": SwiftPMTestProject.defaultPackageManifest, "PackageB/Sources/MyLibrary/libB.swift": """ public struct Lib { @@ -439,7 +439,7 @@ final class WorkspaceTests: XCTestCase { Lib().1️⃣ """, - "PackageB/Package.swift": SwiftPMTestWorkspace.defaultPackageManifest, + "PackageB/Package.swift": SwiftPMTestProject.defaultPackageManifest, ], workspaces: { scratchDir in return [ @@ -513,7 +513,7 @@ final class WorkspaceTests: XCTestCase { } func testMixedPackage() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "clib/include/clib.h": """ #ifndef CLIB_H @@ -569,7 +569,7 @@ final class WorkspaceTests: XCTestCase { func testChangeWorkspaceFolders() async throws { try await SkipUnless.swiftpmStoresModulesInSubdirectory() - let ws = try await MultiFileTestWorkspace( + let ws = try await MultiFileTestProject( files: [ "subdir/Sources/otherPackage/otherPackage.swift": """ import package @@ -701,7 +701,7 @@ final class WorkspaceTests: XCTestCase { } public func testWorkspaceSpecificBuildSettings() async throws { - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "test.swift": """ #if MY_FLAG @@ -744,7 +744,7 @@ final class WorkspaceTests: XCTestCase { try await SkipUnless.swiftpmStoresModulesInSubdirectory() - let ws = try await SwiftPMTestWorkspace( + let ws = try await SwiftPMTestProject( files: [ "Sources/clib/include/clib.h": """ #ifndef CLIB_H