Skip to content

Commit 64e8d21

Browse files
authored
Merge pull request #623 from compnerd/uuids
SourceKitLSPTests: use a UUID in place of `#function`
2 parents b21edcd + 30fbfb8 commit 64e8d21

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

Tests/SourceKitLSPTests/BuildSystemTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ final class BuildSystemTests: XCTestCase {
140140
func testClangdDocumentUpdatedBuildSettings() {
141141
guard haveClangd else { return }
142142

143-
let url = URL(fileURLWithPath: "/\(#function)/file.m")
143+
let url = URL(fileURLWithPath: "/\(UUID())/file.m")
144144
let doc = DocumentURI(url)
145145
let args = [url.path, "-DDEBUG"]
146146
let text = """
@@ -190,7 +190,7 @@ final class BuildSystemTests: XCTestCase {
190190
}
191191

192192
func testSwiftDocumentUpdatedBuildSettings() {
193-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
193+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
194194
let doc = DocumentURI(url)
195195
let args = FallbackBuildSystem(buildSetup: .default).settings(for: doc, .swift)!.compilerArguments
196196

@@ -249,7 +249,7 @@ final class BuildSystemTests: XCTestCase {
249249
func testClangdDocumentFallbackWithholdsDiagnostics() {
250250
guard haveClangd else { return }
251251

252-
let url = URL(fileURLWithPath: "/\(#function)/file.m")
252+
let url = URL(fileURLWithPath: "/\(UUID())/file.m")
253253
let doc = DocumentURI(url)
254254
let args = [url.path, "-DDEBUG"]
255255
let text = """
@@ -298,7 +298,7 @@ final class BuildSystemTests: XCTestCase {
298298
}
299299

300300
func testSwiftDocumentFallbackWithholdsSemanticDiagnostics() {
301-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
301+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
302302
let doc = DocumentURI(url)
303303

304304
// Primary settings must be different than the fallback settings.
@@ -354,7 +354,7 @@ final class BuildSystemTests: XCTestCase {
354354
}
355355

356356
func testSwiftDocumentBuildSettingsChangedFalseAlarm() {
357-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
357+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
358358
let doc = DocumentURI(url)
359359

360360
sk.allowUnexpectedNotification = false

Tests/SourceKitLSPTests/DocumentColorTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class DocumentColorTests: XCTestCase {
4343
}
4444

4545
func performDocumentColorRequest(text: String) -> [ColorInformation] {
46-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
46+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
4747

4848
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
4949
uri: DocumentURI(url),
@@ -56,7 +56,7 @@ final class DocumentColorTests: XCTestCase {
5656
}
5757

5858
func performColorPresentationRequest(text: String, color: Color, range: Range<Position>) -> [ColorPresentation] {
59-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
59+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
6060

6161
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
6262
uri: DocumentURI(url),

Tests/SourceKitLSPTests/DocumentSymbolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class DocumentSymbolTests: XCTestCase {
4646
}
4747

4848
func performDocumentSymbolRequest(text: String) -> DocumentSymbolResponse {
49-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
49+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
5050

5151
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
5252
uri: DocumentURI(url),

Tests/SourceKitLSPTests/InlayHintTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class InlayHintTests: XCTestCase {
4343
}
4444

4545
func performInlayHintRequest(text: String, range: Range<Position>? = nil) throws -> [InlayHint] {
46-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
46+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
4747

4848
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
4949
uri: DocumentURI(url),

Tests/SourceKitLSPTests/LocalSwiftTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final class LocalSwiftTests: XCTestCase {
5858
}
5959

6060
func testEditing() {
61-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
61+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
6262
let uri = DocumentURI(url)
6363

6464
sk.allowUnexpectedNotification = false
@@ -344,8 +344,8 @@ final class LocalSwiftTests: XCTestCase {
344344
}
345345

346346
func testCrossFileDiagnostics() {
347-
let urlA = URL(fileURLWithPath: "/\(#function)/a.swift")
348-
let urlB = URL(fileURLWithPath: "/\(#function)/b.swift")
347+
let urlA = URL(fileURLWithPath: "/\(UUID())/a.swift")
348+
let urlB = URL(fileURLWithPath: "/\(UUID())/b.swift")
349349
let uriA = DocumentURI(urlA)
350350
let uriB = DocumentURI(urlB)
351351

@@ -405,7 +405,7 @@ final class LocalSwiftTests: XCTestCase {
405405
}
406406

407407
func testDiagnosticsReopen() {
408-
let urlA = URL(fileURLWithPath: "/\(#function)/a.swift")
408+
let urlA = URL(fileURLWithPath: "/\(UUID())/a.swift")
409409
let uriA = DocumentURI(urlA)
410410
sk.allowUnexpectedNotification = false
411411

@@ -455,7 +455,7 @@ final class LocalSwiftTests: XCTestCase {
455455
}
456456

457457
func testEducationalNotesAreUsedAsDiagnosticCodes() {
458-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
458+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
459459
let uri = DocumentURI(url)
460460

461461
sk.allowUnexpectedNotification = false
@@ -475,7 +475,7 @@ final class LocalSwiftTests: XCTestCase {
475475
}
476476

477477
func testFixitsAreIncludedInPublishDiagnostics() {
478-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
478+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
479479
let uri = DocumentURI(url)
480480

481481
sk.allowUnexpectedNotification = false
@@ -509,7 +509,7 @@ final class LocalSwiftTests: XCTestCase {
509509
}
510510

511511
func testFixitsAreIncludedInPublishDiagnosticsNotes() {
512-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
512+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
513513
let uri = DocumentURI(url)
514514

515515
sk.allowUnexpectedNotification = false
@@ -562,7 +562,7 @@ final class LocalSwiftTests: XCTestCase {
562562
}
563563

564564
func testFixitInsert() {
565-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
565+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
566566
let uri = DocumentURI(url)
567567

568568
sk.allowUnexpectedNotification = false
@@ -602,7 +602,7 @@ final class LocalSwiftTests: XCTestCase {
602602
}
603603

604604
func testFixitsAreReturnedFromCodeActions() throws {
605-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
605+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
606606
let uri = DocumentURI(url)
607607

608608
var diagnostic: Diagnostic! = nil
@@ -652,7 +652,7 @@ final class LocalSwiftTests: XCTestCase {
652652
}
653653

654654
func testFixitsAreReturnedFromCodeActionsNotes() throws {
655-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
655+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
656656
let uri = DocumentURI(url)
657657

658658
var diagnostic: Diagnostic! = nil
@@ -707,7 +707,7 @@ final class LocalSwiftTests: XCTestCase {
707707
}
708708

709709
func testMuliEditFixitCodeActionPrimary() throws {
710-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
710+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
711711
let uri = DocumentURI(url)
712712

713713
var diagnostic: Diagnostic! = nil
@@ -750,7 +750,7 @@ final class LocalSwiftTests: XCTestCase {
750750
}
751751

752752
func testMuliEditFixitCodeActionNote() throws {
753-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
753+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
754754
let uri = DocumentURI(url)
755755

756756
var diagnostic: Diagnostic! = nil
@@ -1083,7 +1083,7 @@ final class LocalSwiftTests: XCTestCase {
10831083
}
10841084

10851085
func testSymbolInfo() {
1086-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
1086+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
10871087
let uri = DocumentURI(url)
10881088

10891089
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
@@ -1156,7 +1156,7 @@ final class LocalSwiftTests: XCTestCase {
11561156
}
11571157

11581158
func testHover() {
1159-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
1159+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
11601160
let uri = DocumentURI(url)
11611161

11621162
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
@@ -1209,7 +1209,7 @@ final class LocalSwiftTests: XCTestCase {
12091209
}
12101210

12111211
func testHoverNameEscaping() {
1212-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
1212+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
12131213

12141214
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
12151215
uri: DocumentURI(url),
@@ -1274,7 +1274,7 @@ final class LocalSwiftTests: XCTestCase {
12741274
}
12751275

12761276
func testDocumentSymbolHighlight() throws {
1277-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
1277+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
12781278
let uri = DocumentURI(url)
12791279

12801280
sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(

Tests/SourceKitLSPTests/SwiftCompletionTests.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ final class SwiftCompletionTests: XCTestCase {
9999

100100
func testCompletionBasic(options: SKCompletionOptions) throws {
101101
initializeServer(options: options)
102-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
102+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
103103
openDocument(url: url)
104104

105105
let selfDot = try sk.sendSync(CompletionRequest(
@@ -150,7 +150,7 @@ final class SwiftCompletionTests: XCTestCase {
150150
capabilities.completionItem = CompletionCapabilities.CompletionItem(snippetSupport: true)
151151

152152
initializeServer(capabilities: capabilities)
153-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
153+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
154154
openDocument(url: url)
155155

156156
func getTestMethodCompletion(_ position: Position, label: String) throws -> CompletionItem? {
@@ -229,7 +229,7 @@ final class SwiftCompletionTests: XCTestCase {
229229

230230
func testCompletionPosition(options: SKCompletionOptions) throws {
231231
initializeServer(options: options)
232-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
232+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
233233
openDocument(text: "foo", url: url)
234234

235235
for col in 0 ... 3 {
@@ -253,7 +253,7 @@ final class SwiftCompletionTests: XCTestCase {
253253

254254
func testCompletionOptional() throws {
255255
initializeServer()
256-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
256+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
257257
let text = """
258258
struct Foo {
259259
let bar: Int
@@ -279,7 +279,7 @@ final class SwiftCompletionTests: XCTestCase {
279279

280280
func testCompletionOverride() throws {
281281
initializeServer()
282-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
282+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
283283
let text = """
284284
class Base {
285285
func foo() {}
@@ -304,7 +304,7 @@ final class SwiftCompletionTests: XCTestCase {
304304

305305
func testCompletionOverrideInNewLine() throws {
306306
initializeServer()
307-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
307+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
308308
let text = """
309309
class Base {
310310
func foo() {}
@@ -330,7 +330,7 @@ final class SwiftCompletionTests: XCTestCase {
330330

331331
func testMaxResults() throws {
332332
initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))
333-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
333+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
334334
openDocument(text: """
335335
struct S {
336336
func f1() {}
@@ -413,7 +413,7 @@ final class SwiftCompletionTests: XCTestCase {
413413

414414
func testRefilterAfterIncompleteResults() throws {
415415
initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: 20))
416-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
416+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
417417
openDocument(text: """
418418
struct S {
419419
func fooAbc() {}
@@ -474,7 +474,7 @@ final class SwiftCompletionTests: XCTestCase {
474474

475475
func testRefilterAfterIncompleteResultsWithEdits() throws {
476476
initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))
477-
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
477+
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
478478
openDocument(text: """
479479
struct S {
480480
func fooAbc() {}
@@ -555,7 +555,7 @@ final class SwiftCompletionTests: XCTestCase {
555555
/// close waits for its respective open to finish to prevent a session geting stuck open.
556556
func testSessionCloseWaitsforOpen() throws {
557557
initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))
558-
let url = URL(fileURLWithPath: "/\(#function)/file.swift")
558+
let url = URL(fileURLWithPath: "/\(UUID())/file.swift")
559559
openDocument(text: """
560560
struct S {
561561
func forSomethingCrazy() {}

0 commit comments

Comments
 (0)