Skip to content

Commit 5df6ad1

Browse files
authored
Merge pull request #2110 from swiftlang/main
Merge `main` into `release/6.2`
2 parents 462be7e + 6a8ea4c commit 5df6ad1

File tree

10 files changed

+27
-129
lines changed

10 files changed

+27
-129
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.0
1+
// swift-tools-version: 6.1
22

33
import Foundation
44
import PackageDescription

Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package import LanguageServerProtocol
2020
import LanguageServerProtocolExtensions
2121
@preconcurrency import PackageGraph
2222
import PackageLoading
23-
import PackageModel
23+
@preconcurrency import PackageModel
2424
import SKLogging
2525
package import SKOptions
2626
@preconcurrency package import SPMBuildCore

Sources/SKLogging/Logging.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ package typealias LogLevel = os.OSLogType
1919
package typealias Logger = os.Logger
2020
package typealias Signposter = OSSignposter
2121

22-
#if compiler(<5.11)
23-
extension OSSignposter: @unchecked Sendable {}
24-
extension OSSignpostID: @unchecked Sendable {}
25-
extension OSSignpostIntervalState: @unchecked Sendable {}
26-
#else
2722
extension OSSignposter: @retroactive @unchecked Sendable {}
2823
extension OSSignpostID: @retroactive @unchecked Sendable {}
2924
extension OSSignpostIntervalState: @retroactive @unchecked Sendable {}
30-
#endif
3125

3226
extension os.Logger {
3327
package func makeSignposter() -> Signposter {

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -353,30 +353,6 @@ package actor SkipUnless {
353353
return .featureSupported
354354
}
355355
}
356-
357-
/// Checks that swift-format supports running as `swift-format format -` to indicate that the source file should be
358-
/// read from stdin, ie. that swift-format contains https://github.com/swiftlang/swift-format/pull/914.
359-
package static func swiftFormatSupportsDashToIndicateReadingFromStdin(
360-
file: StaticString = #filePath,
361-
line: UInt = #line
362-
) async throws {
363-
return try await shared.skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(6, 1), file: file, line: line) {
364-
guard let swiftFormatPath = await ToolchainRegistry.forTesting.default?.swiftFormat else {
365-
throw GenericError("Could not find swift-format")
366-
}
367-
let process = TSCBasic.Process(arguments: [try swiftFormatPath.filePath, "format", "-"])
368-
let writeStream = try process.launch()
369-
writeStream.send("let x = 1")
370-
try writeStream.close()
371-
let result = try await process.waitUntilExitStoppingProcessOnTaskCancellation()
372-
let output = try result.utf8Output()
373-
switch output {
374-
case "": return false
375-
case "let x = 1\n": return true
376-
default: throw GenericError("Received unexpected formatting output: '\(output)'")
377-
}
378-
}
379-
}
380356
}
381357

382358
// MARK: - Parsing Swift compiler version

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
261261
.failure(ResponseError.unknown("\(R.method) request timed out after \(defaultTimeoutDuration)"))
262262
)
263263
}
264-
await server.handle(notification: CancelRequestNotification(id: requestID))
264+
server.handle(CancelRequestNotification(id: requestID))
265265
}
266266
server.handle(request, id: requestID) { result in
267267
if replyOutstanding.takeValue() ?? false {

Tests/BuildSystemIntegrationTests/SwiftPMBuildSystemTests.swift

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -309,46 +309,6 @@ final class SwiftPMBuildSystemTests: XCTestCase {
309309
}
310310
}
311311

312-
func testDefaultSDKs() async throws {
313-
try await withTestScratchDir { tempDir in
314-
try FileManager.default.createFiles(
315-
root: tempDir,
316-
files: [
317-
"pkg/Sources/lib/a.swift": "",
318-
"pkg/Package.swift": """
319-
// swift-tools-version:6.0
320-
import PackageDescription
321-
let package = Package(
322-
name: "a",
323-
targets: [.target(name: "lib")]
324-
)
325-
""",
326-
]
327-
)
328-
let tr = ToolchainRegistry.forTesting
329-
330-
let options = SourceKitLSPOptions.SwiftPMOptions(
331-
swiftSDKsDirectory: "/tmp/non_existent_sdks_dir",
332-
triple: "wasm32-unknown-wasi"
333-
)
334-
335-
let packageRoot = tempDir.appendingPathComponent("pkg")
336-
let swiftpmBuildSystem = try await SwiftPMBuildSystem(
337-
projectRoot: packageRoot,
338-
toolchainRegistry: tr,
339-
options: SourceKitLSPOptions(swiftPM: options),
340-
connectionToSourceKitLSP: LocalConnection(receiverName: "Dummy"),
341-
testHooks: SwiftPMTestHooks()
342-
)
343-
let path = await swiftpmBuildSystem.destinationBuildParameters.toolchain.sdkRootPath
344-
XCTAssertEqual(
345-
path?.components.suffix(3),
346-
["usr", "share", "wasi-sysroot"],
347-
"SwiftPMBuildSystem should share default SDK derivation logic with libSwiftPM"
348-
)
349-
}
350-
}
351-
352312
func testManifestArgs() async throws {
353313
try await withTestScratchDir { tempDir in
354314
try FileManager.default.createFiles(

Tests/SourceKitLSPTests/FormattingTests.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import class TSCBasic.Process
2222

2323
final class FormattingTests: XCTestCase {
2424
func testFormatting() async throws {
25-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
26-
2725
let testClient = try await TestSourceKitLSPClient()
2826
let uri = DocumentURI(for: .swift)
2927

@@ -57,8 +55,6 @@ final class FormattingTests: XCTestCase {
5755
}
5856

5957
func testFormattingNoEdits() async throws {
60-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
61-
6258
let testClient = try await TestSourceKitLSPClient()
6359
let uri = DocumentURI(for: .swift)
6460

@@ -84,8 +80,6 @@ final class FormattingTests: XCTestCase {
8480
}
8581

8682
func testConfigFileOnDisk() async throws {
87-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
88-
8983
// We pick up an invalid swift-format configuration file and thus don't set the user-provided options.
9084
let project = try await MultiFileTestProject(files: [
9185
".swift-format": """
@@ -120,8 +114,6 @@ final class FormattingTests: XCTestCase {
120114
}
121115

122116
func testConfigFileInParentDirectory() async throws {
123-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
124-
125117
// We pick up an invalid swift-format configuration file and thus don't set the user-provided options.
126118
let project = try await MultiFileTestProject(files: [
127119
".swift-format": """
@@ -156,8 +148,6 @@ final class FormattingTests: XCTestCase {
156148
}
157149

158150
func testConfigFileInNestedDirectory() async throws {
159-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
160-
161151
// We pick up an invalid swift-format configuration file and thus don't set the user-provided options.
162152
let project = try await MultiFileTestProject(files: [
163153
".swift-format": """
@@ -200,8 +190,6 @@ final class FormattingTests: XCTestCase {
200190
}
201191

202192
func testInvalidConfigurationFile() async throws {
203-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
204-
205193
// We pick up an invalid swift-format configuration file and thus don't set the user-provided options.
206194
// The swift-format default is 2 spaces.
207195
let project = try await MultiFileTestProject(files: [
@@ -226,8 +214,6 @@ final class FormattingTests: XCTestCase {
226214
}
227215

228216
func testInsertAndRemove() async throws {
229-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
230-
231217
let testClient = try await TestSourceKitLSPClient()
232218
let uri = DocumentURI(for: .swift)
233219

@@ -259,8 +245,6 @@ final class FormattingTests: XCTestCase {
259245
}
260246

261247
func testMultiLineStringInsertion() async throws {
262-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
263-
264248
let testClient = try await TestSourceKitLSPClient()
265249
let uri = DocumentURI(for: .swift)
266250

Tests/SourceKitLSPTests/OnTypeFormattingTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import XCTest
1818

1919
final class OnTypeFormattingTests: XCTestCase {
2020
func testOnlyFormatsSpecifiedLine() async throws {
21-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
22-
2321
let testClient = try await TestSourceKitLSPClient()
2422
let uri = DocumentURI(for: .swift)
2523

@@ -53,8 +51,6 @@ final class OnTypeFormattingTests: XCTestCase {
5351
}
5452

5553
func testFormatsFullLineAndDoesNotFormatNextLine() async throws {
56-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
57-
5854
let testClient = try await TestSourceKitLSPClient()
5955
let uri = DocumentURI(for: .swift)
6056

@@ -92,8 +88,6 @@ final class OnTypeFormattingTests: XCTestCase {
9288
/// Otherwise could mess up writing code. You'd write {} and try to go into the braces to write more code,
9389
/// only for on-type formatting to immediately close the braces again.
9490
func testDoesNothingWhenInAnEmptyLine() async throws {
95-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
96-
9791
let testClient = try await TestSourceKitLSPClient()
9892
let uri = DocumentURI(for: .swift)
9993

Tests/SourceKitLSPTests/PullDiagnosticsTests.swift

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -329,37 +329,34 @@ final class PullDiagnosticsTests: XCTestCase {
329329
}
330330

331331
func testDontReturnEmptyDiagnosticsIfDiagnosticRequestIsCancelled() async throws {
332-
let diagnosticRequestCancelled = MultiEntrySemaphore(name: "diagnostic request cancelled")
333-
let packageLoadingDidFinish = self.expectation(description: "Package loading did finish")
334-
var testHooks = Hooks()
335-
testHooks.buildSystemHooks.swiftPMTestHooks.reloadPackageDidFinish = {
336-
packageLoadingDidFinish.fulfill()
337-
}
338-
testHooks.indexHooks.preparationTaskDidStart = { _ in
339-
await diagnosticRequestCancelled.waitOrXCTFail()
340-
// Poll until the `CancelRequestNotification` has been propagated to the request handling.
341-
// We can't use `repeatUntilExpectedResult` here because that throws a `CancellationError` when the preparation is
342-
// cancelled.
343-
for _ in 0..<Int(defaultTimeout * 100) {
344-
if Task.isCancelled {
345-
break
346-
}
347-
#if os(Windows)
348-
Sleep(10 /*ms*/)
349-
#else
350-
usleep(10_000 /*µs*/)
351-
#endif
352-
}
353-
}
332+
// Use an example that is slow to type check to ensure that we don't get a diagnostic response from sourcekitd
333+
// before the request cancellation gets handled.
354334
let project = try await SwiftPMTestProject(
355335
files: [
356-
"Lib.swift": "let x: String = 1"
336+
"Lib.swift": """
337+
struct A: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
338+
struct B: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
339+
struct C: ExpressibleByIntegerLiteral { init(integerLiteral value: Int) {} }
340+
341+
func + (lhs: A, rhs: B) -> A { fatalError() }
342+
func + (lhs: B, rhs: C) -> A { fatalError() }
343+
func + (lhs: C, rhs: A) -> A { fatalError() }
344+
345+
func + (lhs: B, rhs: A) -> B { fatalError() }
346+
func + (lhs: C, rhs: B) -> B { fatalError() }
347+
func + (lhs: A, rhs: C) -> B { fatalError() }
348+
349+
func + (lhs: C, rhs: B) -> C { fatalError() }
350+
func + (lhs: B, rhs: C) -> C { fatalError() }
351+
func + (lhs: A, rhs: A) -> C { fatalError() }
352+
353+
func slow() {
354+
let x: C = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
355+
}
356+
"""
357357
],
358-
hooks: testHooks,
359-
enableBackgroundIndexing: true,
360-
pollIndex: false
358+
enableBackgroundIndexing: false
361359
)
362-
try await fulfillmentOfOrThrow(packageLoadingDidFinish)
363360
let (uri, _) = try project.openDocument("Lib.swift")
364361

365362
let diagnosticResponseReceived = self.expectation(description: "Received diagnostic response")
@@ -370,7 +367,6 @@ final class PullDiagnosticsTests: XCTestCase {
370367
diagnosticResponseReceived.fulfill()
371368
}
372369
project.testClient.send(CancelRequestNotification(id: requestID))
373-
diagnosticRequestCancelled.signal()
374370
try await fulfillmentOfOrThrow(diagnosticResponseReceived)
375371
}
376372

Tests/SourceKitLSPTests/RangeFormattingTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import XCTest
1818

1919
final class RangeFormattingTests: XCTestCase {
2020
func testOnlyFormatsSpecifiedLines() async throws {
21-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
22-
2321
let testClient = try await TestSourceKitLSPClient()
2422
let uri = DocumentURI(for: .swift)
2523

@@ -52,8 +50,6 @@ final class RangeFormattingTests: XCTestCase {
5250
}
5351

5452
func testOnlyFormatsSpecifiedColumns() async throws {
55-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
56-
5753
let testClient = try await TestSourceKitLSPClient()
5854
let uri = DocumentURI(for: .swift)
5955

@@ -86,8 +82,6 @@ final class RangeFormattingTests: XCTestCase {
8682
}
8783

8884
func testFormatsMultipleLines() async throws {
89-
try await SkipUnless.swiftFormatSupportsDashToIndicateReadingFromStdin()
90-
9185
let testClient = try await TestSourceKitLSPClient()
9286
let uri = DocumentURI(for: .swift)
9387

0 commit comments

Comments
 (0)