Skip to content

Commit 1611716

Browse files
committed
Rename test projects for consistency
Rename all the classes that write files to disk to create a test project that we can open in sourcekit-lsp to end with `TestProject`. This is better than the old `Workspace` suffix because it avoids ambiguities with the `Workspace` type inside sourcekit-lsp. - IndexedSingleSwiftFileWorkspace -> IndexedSingleSwiftFileTestProject - MultiFileTestWorkspace -> MultiFileTestProject - SwiftPMTestWorkspace -> SwiftPMTestProject
1 parent 4b5f7ff commit 1611716

27 files changed

+94
-94
lines changed

Sources/SKTestSupport/IndexedSingleSwiftFileWorkspace.swift renamed to Sources/SKTestSupport/IndexedSingleSwiftFileTestProject.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import LanguageServerProtocol
1717
import SourceKitLSP
1818
import TSCBasic
1919

20-
public struct IndexedSingleSwiftFileWorkspace {
20+
public struct IndexedSingleSwiftFileTestProject {
2121
enum Error: Swift.Error {
2222
case swiftcNotFound
2323
}

Sources/SKTestSupport/MultiFileTestWorkspace.swift renamed to Sources/SKTestSupport/MultiFileTestProject.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public struct RelativeFileLocation: Hashable, ExpressibleByStringLiteral {
3333
}
3434
}
3535

36-
/// A workspace that writes multiple files to disk and opens a `TestSourceKitLSPClient` client with a workspace pointing
37-
/// to a temporary directory containing those files.
36+
/// A test project that writes multiple files to disk and opens a `TestSourceKitLSPClient` client with a workspace
37+
/// pointing to a temporary directory containing those files.
3838
///
3939
/// The temporary files will be deleted when the `TestSourceKitLSPClient` is destructed.
40-
public class MultiFileTestWorkspace {
40+
public class MultiFileTestProject {
4141
/// Information necessary to open a file in the LSP server by its filename.
4242
private struct FileData {
4343
/// The URI at which the file is stored on disk.
@@ -53,7 +53,7 @@ public class MultiFileTestWorkspace {
5353
private let fileData: [String: FileData]
5454

5555
enum Error: Swift.Error {
56-
/// No file with the given filename is known to the `SwiftPMTestWorkspace`.
56+
/// No file with the given filename is known to the `MultiFileTestProject`.
5757
case fileNotFound
5858
}
5959

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public enum SkipUnless {
180180
line: UInt = #line
181181
) async throws {
182182
try await skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(5, 11), file: file, line: line) {
183-
let workspace = try await SwiftPMTestWorkspace(
183+
let workspace = try await SwiftPMTestProject(
184184
files: ["test.swift": ""],
185185
build: true
186186
)

Sources/SKTestSupport/SwiftPMTestWorkspace.swift renamed to Sources/SKTestSupport/SwiftPMTestProject.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import LanguageServerProtocol
1515
@_spi(Testing) import SKCore
1616
import TSCBasic
1717

18-
public class SwiftPMTestWorkspace: MultiFileTestWorkspace {
18+
public class SwiftPMTestProject: MultiFileTestProject {
1919
enum Error: Swift.Error {
2020
/// The `swift` executable could not be found.
2121
case swiftNotFound
@@ -37,7 +37,7 @@ public class SwiftPMTestWorkspace: MultiFileTestWorkspace {
3737
/// If `index` is `true`, then the package will be built, indexing all modules within the package.
3838
public init(
3939
files: [RelativeFileLocation: String],
40-
manifest: String = SwiftPMTestWorkspace.defaultPackageManifest,
40+
manifest: String = SwiftPMTestProject.defaultPackageManifest,
4141
workspaces: (URL) -> [WorkspaceFolder] = { [WorkspaceFolder(uri: DocumentURI($0))] },
4242
build: Bool = false,
4343
usePullDiagnostics: Bool = true,

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
7070

7171
/// A closure that is called when the `TestSourceKitLSPClient` is destructed.
7272
///
73-
/// This allows e.g. a `IndexedSingleSwiftFileWorkspace` to delete its temporary files when they are no longer needed.
73+
/// This allows e.g. a `IndexedSingleSwiftFileTestProject` to delete its temporary files when they are no longer needed.
7474
private let cleanUp: () -> Void
7575

7676
/// - Parameters:
@@ -84,7 +84,7 @@ public final class TestSourceKitLSPClient: MessageHandler {
8484
/// - usePullDiagnostics: Whether to use push diagnostics or use push-based diagnostics
8585
/// - workspaceFolders: Workspace folders to open.
8686
/// - cleanUp: A closure that is called when the `TestSourceKitLSPClient` is destructed.
87-
/// This allows e.g. a `IndexedSingleSwiftFileWorkspace` to delete its temporary files when they are no longer
87+
/// This allows e.g. a `IndexedSingleSwiftFileTestProject` to delete its temporary files when they are no longer
8888
/// needed.
8989
public init(
9090
serverOptions: SourceKitLSPServer.Options = .testDefault,

Tests/SourceKitDTests/CrashRecoveryTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ final class CrashRecoveryTests: XCTestCase {
202202
func testClangdCrashRecoveryReopensWithCorrectBuildSettings() async throws {
203203
try SkipUnless.longTestsEnabled()
204204

205-
let ws = try await MultiFileTestWorkspace(files: [
205+
let ws = try await MultiFileTestProject(files: [
206206
"main.cpp": """
207207
#if FOO
208208
void 1️⃣foo2️⃣() {}

Tests/SourceKitLSPTests/CallHierarchyTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import XCTest
1919

2020
final class CallHierarchyTests: XCTestCase {
2121
func testCallHierarchy() async throws {
22-
let ws = try await IndexedSingleSwiftFileWorkspace(
22+
let ws = try await IndexedSingleSwiftFileTestProject(
2323
"""
2424
func 1️⃣a() {}
2525
@@ -185,7 +185,7 @@ final class CallHierarchyTests: XCTestCase {
185185
}
186186

187187
func testReportSingleItemInPrepareCallHierarchy() async throws {
188-
let ws = try await SwiftPMTestWorkspace(
188+
let ws = try await SwiftPMTestProject(
189189
files: [
190190
"MyLibrary/include/lib.h": """
191191
struct FilePathIndex {
@@ -227,7 +227,7 @@ final class CallHierarchyTests: XCTestCase {
227227

228228
func testIncomingCallHierarchyShowsSurroundingFunctionCall() async throws {
229229
// We used to show `myVar` as the caller here
230-
let ws = try await IndexedSingleSwiftFileWorkspace(
230+
let ws = try await IndexedSingleSwiftFileTestProject(
231231
"""
232232
func 1️⃣foo() {}
233233
@@ -268,7 +268,7 @@ final class CallHierarchyTests: XCTestCase {
268268
}
269269

270270
func testIncomingCallHierarchyFromComputedProperty() async throws {
271-
let ws = try await IndexedSingleSwiftFileWorkspace(
271+
let ws = try await IndexedSingleSwiftFileTestProject(
272272
"""
273273
func 1️⃣foo() {}
274274
@@ -310,7 +310,7 @@ final class CallHierarchyTests: XCTestCase {
310310
}
311311

312312
func testIncomingCallHierarchyShowsAccessToVariables() async throws {
313-
let ws = try await IndexedSingleSwiftFileWorkspace(
313+
let ws = try await IndexedSingleSwiftFileTestProject(
314314
"""
315315
var 1️⃣foo: Int
316316
func 2️⃣testFunc() {
@@ -368,7 +368,7 @@ final class CallHierarchyTests: XCTestCase {
368368
}
369369

370370
func testOutgoingCallHierarchyShowsAccessesToVariable() async throws {
371-
let ws = try await IndexedSingleSwiftFileWorkspace(
371+
let ws = try await IndexedSingleSwiftFileTestProject(
372372
"""
373373
var 1️⃣foo: Int
374374
func 2️⃣testFunc() {
@@ -409,7 +409,7 @@ final class CallHierarchyTests: XCTestCase {
409409
}
410410

411411
func testOutgoingCallHierarchyFromVariableAccessor() async throws {
412-
let ws = try await IndexedSingleSwiftFileWorkspace(
412+
let ws = try await IndexedSingleSwiftFileTestProject(
413413
"""
414414
func 1️⃣testFunc() -> Int { 0 }
415415
var 2️⃣foo: Int {
@@ -449,7 +449,7 @@ final class CallHierarchyTests: XCTestCase {
449449
}
450450

451451
func testIncomingCallHierarchyLooksThroughProtocols() async throws {
452-
let ws = try await IndexedSingleSwiftFileWorkspace(
452+
let ws = try await IndexedSingleSwiftFileTestProject(
453453
"""
454454
protocol MyProtocol {
455455
func foo()
@@ -498,7 +498,7 @@ final class CallHierarchyTests: XCTestCase {
498498
}
499499

500500
func testIncomingCallHierarchyLooksThroughSuperclasses() async throws {
501-
let ws = try await IndexedSingleSwiftFileWorkspace(
501+
let ws = try await IndexedSingleSwiftFileTestProject(
502502
"""
503503
class Base {
504504
func foo() {}

Tests/SourceKitLSPTests/ClangdTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import XCTest
1616

1717
final class ClangdTests: XCTestCase {
1818
func testClangdGoToInclude() async throws {
19-
let ws = try await MultiFileTestWorkspace(files: [
19+
let ws = try await MultiFileTestProject(files: [
2020
"Object.h": "",
2121
"main.c": """
2222
#include 1️⃣"Object.h"
@@ -47,7 +47,7 @@ final class ClangdTests: XCTestCase {
4747
}
4848

4949
func testClangdGoToDefinitionWithoutIndex() async throws {
50-
let ws = try await MultiFileTestWorkspace(files: [
50+
let ws = try await MultiFileTestProject(files: [
5151
"Object.h": """
5252
struct Object {
5353
int field;
@@ -87,7 +87,7 @@ final class ClangdTests: XCTestCase {
8787
}
8888

8989
func testClangdGoToDeclaration() async throws {
90-
let ws = try await MultiFileTestWorkspace(files: [
90+
let ws = try await MultiFileTestProject(files: [
9191
"Object.h": """
9292
struct Object {
9393
int field;

Tests/SourceKitLSPTests/CodeActionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ final class CodeActionTests: XCTestCase {
430430
}
431431

432432
func testCodeActionForFixItsProducedBySwiftSyntax() async throws {
433-
let ws = try await MultiFileTestWorkspace(files: [
433+
let ws = try await MultiFileTestProject(files: [
434434
"test.swift": "protocol 1️⃣Multi 2️⃣ident 3️⃣{}",
435435
"compile_commands.json": "[]",
436436
])

Tests/SourceKitLSPTests/CompilationDatabaseTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import XCTest
1919

2020
final class CompilationDatabaseTests: XCTestCase {
2121
func testModifyCompilationDatabase() async throws {
22-
let ws = try await MultiFileTestWorkspace(files: [
22+
let ws = try await MultiFileTestProject(files: [
2323
"main.cpp": """
2424
#if FOO
2525
void 1️⃣foo2️⃣() {}

0 commit comments

Comments
 (0)