Skip to content

Commit 1cd1102

Browse files
committed
Introduce defaultTimeoutDuration to get the default timeout as a Duration
1 parent 71dfc73 commit 1cd1102

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

Sources/Diagnose/TraceFromSignpostsCommand.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import Foundation
1515
import RegexBuilder
1616
import SwiftExtensions
1717

18-
import class TSCBasic.Process
19-
2018
/// Shared instance of the regex that is used to extract Signpost lines from `log stream --signpost`.
2119
fileprivate struct LogParseRegex {
2220
@MainActor static let shared = LogParseRegex()

Sources/SKTestSupport/RepeatUntilExpectedResult.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import XCTest
2121
///
2222
/// `sleepInterval` is the duration to wait before re-executing the body.
2323
package func repeatUntilExpectedResult(
24-
timeout: Duration = .seconds(defaultTimeout),
24+
timeout: Duration = defaultTimeoutDuration,
2525
sleepInterval: Duration = .seconds(1),
2626
_ body: () async throws -> Bool,
2727
file: StaticString = #filePath,

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ package actor SkipUnless {
266266
sourcekitd.keys.useNewAPI: 1
267267
],
268268
]),
269-
timeout: .seconds(defaultTimeout),
269+
timeout: defaultTimeoutDuration,
270270
fileContents: nil
271271
)
272272
return response[sourcekitd.keys.useNewAPI] == 1

Sources/SKTestSupport/TestSourceKitLSPClient.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
197197
preInitialization?(self)
198198
if initialize {
199199
let capabilities = capabilities
200-
try await withTimeout(.seconds(defaultTimeout)) {
200+
try await withTimeout(defaultTimeoutDuration) {
201201
_ = try await self.send(
202202
InitializeRequest(
203203
processId: nil,
@@ -270,7 +270,7 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
270270
///
271271
/// - Note: This also returns any notifications sent before the call to
272272
/// `nextNotification`.
273-
package func nextNotification(timeout: Duration = .seconds(defaultTimeout)) async throws -> any NotificationType {
273+
package func nextNotification(timeout: Duration = defaultTimeoutDuration) async throws -> any NotificationType {
274274
return try await notifications.next(timeout: timeout)
275275
}
276276

@@ -279,7 +279,7 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
279279
/// If the next notification is not a `PublishDiagnosticsNotification`, this
280280
/// methods throws.
281281
package func nextDiagnosticsNotification(
282-
timeout: Duration = .seconds(defaultTimeout)
282+
timeout: Duration = defaultTimeoutDuration
283283
) async throws -> PublishDiagnosticsNotification {
284284
guard !usePullDiagnostics else {
285285
struct PushDiagnosticsError: Error, CustomStringConvertible {
@@ -295,7 +295,7 @@ package final class TestSourceKitLSPClient: MessageHandler, Sendable {
295295
package func nextNotification<ExpectedNotificationType: NotificationType>(
296296
ofType: ExpectedNotificationType.Type,
297297
satisfying predicate: (ExpectedNotificationType) throws -> Bool = { _ in true },
298-
timeout: Duration = .seconds(defaultTimeout)
298+
timeout: Duration = defaultTimeoutDuration
299299
) async throws -> ExpectedNotificationType {
300300
while true {
301301
let nextNotification = try await nextNotification(timeout: timeout)

Sources/SKTestSupport/Timeouts.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ package let defaultTimeout: TimeInterval = {
2222
}
2323
return 180
2424
}()
25+
26+
package var defaultTimeoutDuration: Duration { .seconds(defaultTimeout) }

Tests/SourceKitDTests/SourceKitDTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ final class SourceKitDTests: XCTestCase {
8484
keys.compilerArgs: args,
8585
])
8686

87-
_ = try await sourcekitd.send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
87+
_ = try await sourcekitd.send(req, timeout: defaultTimeoutDuration, fileContents: nil)
8888

8989
try await fulfillmentOfOrThrow([expectation1, expectation2])
9090

9191
let close = sourcekitd.dictionary([
9292
keys.request: sourcekitd.requests.editorClose,
9393
keys.name: path,
9494
])
95-
_ = try await sourcekitd.send(close, timeout: .seconds(defaultTimeout), fileContents: nil)
95+
_ = try await sourcekitd.send(close, timeout: defaultTimeoutDuration, fileContents: nil)
9696
}
9797
}
9898

Tests/SwiftSourceKitPluginTests/SwiftSourceKitPluginTests.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ fileprivate extension SourceKitD {
18261826
keys.syntacticOnly: 1,
18271827
keys.compilerArgs: compilerArguments as [SKDRequestValue],
18281828
])
1829-
_ = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1829+
_ = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
18301830
return DocumentPositions(markers: markers, textWithoutMarkers: textWithoutMarkers)
18311831
}
18321832

@@ -1840,7 +1840,7 @@ fileprivate extension SourceKitD {
18401840
keys.syntacticOnly: 1,
18411841
])
18421842

1843-
_ = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1843+
_ = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
18441844
}
18451845

18461846
func closeDocument(_ name: String) async throws {
@@ -1849,7 +1849,7 @@ fileprivate extension SourceKitD {
18491849
keys.name: name,
18501850
])
18511851

1852-
_ = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1852+
_ = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
18531853
}
18541854

18551855
func completeImpl(
@@ -1884,7 +1884,7 @@ fileprivate extension SourceKitD {
18841884
keys.compilerArgs: compilerArguments as [SKDRequestValue]?,
18851885
])
18861886

1887-
let res = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1887+
let res = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
18881888
return try CompletionResultSet(res)
18891889
}
18901890

@@ -1942,7 +1942,7 @@ fileprivate extension SourceKitD {
19421942
keys.codeCompleteOptions: dictionary([keys.useNewAPI: 1]),
19431943
])
19441944

1945-
_ = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1945+
_ = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
19461946
}
19471947

19481948
func completeDocumentation(id: Int) async throws -> CompletionDocumentation {
@@ -1951,7 +1951,7 @@ fileprivate extension SourceKitD {
19511951
keys.identifier: id,
19521952
])
19531953

1954-
let resp = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1954+
let resp = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
19551955
return CompletionDocumentation(resp)
19561956
}
19571957

@@ -1960,7 +1960,7 @@ fileprivate extension SourceKitD {
19601960
keys.request: requests.codeCompleteDiagnostic,
19611961
keys.identifier: id,
19621962
])
1963-
let resp = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1963+
let resp = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
19641964

19651965
return CompletionDiagnostic(resp)
19661966
}
@@ -1969,7 +1969,7 @@ fileprivate extension SourceKitD {
19691969
let req = dictionary([
19701970
keys.request: requests.dependencyUpdated
19711971
])
1972-
_ = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1972+
_ = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
19731973
}
19741974

19751975
func setPopularAPI(popular: [String], unpopular: [String]) async throws {
@@ -1980,7 +1980,7 @@ fileprivate extension SourceKitD {
19801980
keys.unpopular: unpopular as [SKDRequestValue],
19811981
])
19821982

1983-
let resp = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
1983+
let resp = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
19841984
XCTAssertEqual(resp[keys.useNewAPI], 1)
19851985
}
19861986

@@ -1997,7 +1997,7 @@ fileprivate extension SourceKitD {
19971997
keys.notoriousModules: notoriousModules as [SKDRequestValue],
19981998
])
19991999

2000-
let resp = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
2000+
let resp = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
20012001
XCTAssertEqual(resp[keys.useNewAPI], 1)
20022002
}
20032003

@@ -2021,7 +2021,7 @@ fileprivate extension SourceKitD {
20212021
keys.modulePopularity: modulePopularity as [SKDRequestValue],
20222022
])
20232023

2024-
let resp = try await send(req, timeout: .seconds(defaultTimeout), fileContents: nil)
2024+
let resp = try await send(req, timeout: defaultTimeoutDuration, fileContents: nil)
20252025
XCTAssertEqual(resp[keys.useNewAPI], 1)
20262026
}
20272027

0 commit comments

Comments
 (0)