Skip to content

SourceKitLSPTests: use a UUID in place of #function #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Tests/SourceKitLSPTests/BuildSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class BuildSystemTests: XCTestCase {
func testClangdDocumentUpdatedBuildSettings() {
guard haveClangd else { return }

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

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

Expand Down Expand Up @@ -249,7 +249,7 @@ final class BuildSystemTests: XCTestCase {
func testClangdDocumentFallbackWithholdsDiagnostics() {
guard haveClangd else { return }

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

func testSwiftDocumentFallbackWithholdsSemanticDiagnostics() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let doc = DocumentURI(url)

// Primary settings must be different than the fallback settings.
Expand Down Expand Up @@ -354,7 +354,7 @@ final class BuildSystemTests: XCTestCase {
}

func testSwiftDocumentBuildSettingsChangedFalseAlarm() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let doc = DocumentURI(url)

sk.allowUnexpectedNotification = false
Expand Down
4 changes: 2 additions & 2 deletions Tests/SourceKitLSPTests/DocumentColorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class DocumentColorTests: XCTestCase {
}

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

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

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

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
uri: DocumentURI(url),
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/DocumentSymbolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class DocumentSymbolTests: XCTestCase {
}

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

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
uri: DocumentURI(url),
Expand Down
2 changes: 1 addition & 1 deletion Tests/SourceKitLSPTests/InlayHintTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class InlayHintTests: XCTestCase {
}

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

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
uri: DocumentURI(url),
Expand Down
32 changes: 16 additions & 16 deletions Tests/SourceKitLSPTests/LocalSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testEditing() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.allowUnexpectedNotification = false
Expand Down Expand Up @@ -344,8 +344,8 @@ final class LocalSwiftTests: XCTestCase {
}

func testCrossFileDiagnostics() {
let urlA = URL(fileURLWithPath: "/\(#function)/a.swift")
let urlB = URL(fileURLWithPath: "/\(#function)/b.swift")
let urlA = URL(fileURLWithPath: "/\(UUID())/a.swift")
let urlB = URL(fileURLWithPath: "/\(UUID())/b.swift")
let uriA = DocumentURI(urlA)
let uriB = DocumentURI(urlB)

Expand Down Expand Up @@ -405,7 +405,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testDiagnosticsReopen() {
let urlA = URL(fileURLWithPath: "/\(#function)/a.swift")
let urlA = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uriA = DocumentURI(urlA)
sk.allowUnexpectedNotification = false

Expand Down Expand Up @@ -455,7 +455,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testEducationalNotesAreUsedAsDiagnosticCodes() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.allowUnexpectedNotification = false
Expand All @@ -475,7 +475,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testFixitsAreIncludedInPublishDiagnostics() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.allowUnexpectedNotification = false
Expand Down Expand Up @@ -509,7 +509,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testFixitsAreIncludedInPublishDiagnosticsNotes() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.allowUnexpectedNotification = false
Expand Down Expand Up @@ -562,7 +562,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testFixitInsert() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.allowUnexpectedNotification = false
Expand Down Expand Up @@ -602,7 +602,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testFixitsAreReturnedFromCodeActions() throws {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

var diagnostic: Diagnostic! = nil
Expand Down Expand Up @@ -652,7 +652,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testFixitsAreReturnedFromCodeActionsNotes() throws {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

var diagnostic: Diagnostic! = nil
Expand Down Expand Up @@ -707,7 +707,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testMuliEditFixitCodeActionPrimary() throws {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

var diagnostic: Diagnostic! = nil
Expand Down Expand Up @@ -750,7 +750,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testMuliEditFixitCodeActionNote() throws {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

var diagnostic: Diagnostic! = nil
Expand Down Expand Up @@ -1083,7 +1083,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testSymbolInfo() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
Expand Down Expand Up @@ -1156,7 +1156,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testHover() {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
Expand Down Expand Up @@ -1209,7 +1209,7 @@ final class LocalSwiftTests: XCTestCase {
}

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

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
uri: DocumentURI(url),
Expand Down Expand Up @@ -1274,7 +1274,7 @@ final class LocalSwiftTests: XCTestCase {
}

func testDocumentSymbolHighlight() throws {
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
let uri = DocumentURI(url)

sk.send(DidOpenTextDocumentNotification(textDocument: TextDocumentItem(
Expand Down
20 changes: 10 additions & 10 deletions Tests/SourceKitLSPTests/SwiftCompletionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ final class SwiftCompletionTests: XCTestCase {

func testCompletionBasic(options: SKCompletionOptions) throws {
initializeServer(options: options)
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
openDocument(url: url)

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

initializeServer(capabilities: capabilities)
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
openDocument(url: url)

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

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

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

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

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

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

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

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

func testRefilterAfterIncompleteResultsWithEdits() throws {
initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))
let url = URL(fileURLWithPath: "/\(#function)/a.swift")
let url = URL(fileURLWithPath: "/\(UUID())/a.swift")
openDocument(text: """
struct S {
func fooAbc() {}
Expand Down Expand Up @@ -555,7 +555,7 @@ final class SwiftCompletionTests: XCTestCase {
/// close waits for its respective open to finish to prevent a session geting stuck open.
func testSessionCloseWaitsforOpen() throws {
initializeServer(options: SKCompletionOptions(serverSideFiltering: true, maxResults: nil))
let url = URL(fileURLWithPath: "/\(#function)/file.swift")
let url = URL(fileURLWithPath: "/\(UUID())/file.swift")
openDocument(text: """
struct S {
func forSomethingCrazy() {}
Expand Down