Skip to content
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
31 changes: 31 additions & 0 deletions Sources/SKTestSupport/SkipUnless.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,37 @@ public actor SkipUnless {
}
}

/// Checks if the toolchain contains https://github.com/apple/swift/pull/74080.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what to do about this, but the skip test is really the test itself 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know. The key point here is that it won’t skip the test if the toolchain is ≥6.1 or if we are on Swift CI (SWIFTCI_USE_LOCAL_DEPS is set – https://github.com/apple/sourcekit-lsp/blob/main/Documentation/Environment%20Variables.md#build-time)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, my point was more that it would skip if the original test would fail, though depends on the failure (ie. if more results are returned then it wouldn't skip, but if the result is missing at all then it will). Anyway, I think it's fine 👍

public static func sourcekitdReportsOverridableFunctionDefinitionsAsDynamic(
file: StaticString = #filePath,
line: UInt = #line
) async throws {
struct ExpectedLocationsResponse: Error {}

return try await shared.skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(6, 0), file: file, line: line) {
let project = try await IndexedSingleSwiftFileTestProject(
"""
protocol TestProtocol {
func 1️⃣doThing()
}

struct TestImpl: TestProtocol {}
extension TestImpl {
func 2️⃣doThing() { }
}
"""
)

let response = try await project.testClient.send(
DefinitionRequest(textDocument: TextDocumentIdentifier(project.fileURI), position: project.positions["1️⃣"])
)
guard case .locations(let locations) = response else {
throw ExpectedLocationsResponse()
}
return locations.contains { $0.range == Range(project.positions["2️⃣"]) }
}
}

public static func sourcekitdReturnsRawDocumentationResponse(
file: StaticString = #filePath,
line: UInt = #line
Expand Down
2 changes: 2 additions & 0 deletions Tests/SourceKitLSPTests/DefinitionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ class DefinitionTests: XCTestCase {
}

func testJumpToSatisfiedProtocolRequirementInExtension() async throws {
try await SkipUnless.sourcekitdReportsOverridableFunctionDefinitionsAsDynamic()

let project = try await IndexedSingleSwiftFileTestProject(
"""
protocol TestProtocol {
Expand Down