Skip to content

Commit a74e32f

Browse files
committed
account for swift 6 sendable's house of cards
1 parent 149d789 commit a74e32f

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

Diff for: Coder-Desktop/Coder-DesktopTests/FilePickerTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ struct FilePickerTests {
103103
try disclosureGroup.expand()
104104

105105
// Disclosure group should expand out to 3 more directories
106-
try #expect(await eventually { @MainActor in
107-
return try view.findAll(ViewType.DisclosureGroup.self).count == 6
106+
#expect(await eventually { @MainActor in
107+
return view.findAll(ViewType.DisclosureGroup.self).count == 6
108108
})
109109
}
110110
}

Diff for: Coder-Desktop/Coder-DesktopTests/FileSyncDaemonTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class FileSyncDaemonTests {
8181
// Write a file to Alpha
8282
let alphaFile = mutagenAlphaDirectory.appendingPathComponent("test.txt")
8383
try "Hello, World!".write(to: alphaFile, atomically: true, encoding: .utf8)
84-
try #expect(
84+
#expect(
8585
await eventually(timeout: .seconds(5), interval: .milliseconds(100)) { @MainActor in
86-
return try FileManager.default.fileExists(
86+
return FileManager.default.fileExists(
8787
atPath: self.mutagenBetaDirectory.appending(path: "test.txt").path()
8888
)
8989
})

Diff for: Coder-Desktop/Coder-DesktopTests/Util.swift

+3-10
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,19 @@ extension Inspection: @unchecked Sendable, @retroactive InspectionEmissary {}
6161
public func eventually(
6262
timeout: Duration = .milliseconds(500),
6363
interval: Duration = .milliseconds(10),
64-
condition: @escaping () async throws -> Bool
65-
) async throws -> Bool {
64+
condition: @Sendable () async throws -> Bool
65+
) async rethrows -> Bool {
6666
let endTime = ContinuousClock.now.advanced(by: timeout)
6767

68-
var lastError: Error?
69-
7068
while ContinuousClock.now < endTime {
7169
do {
7270
if try await condition() { return true }
73-
lastError = nil
7471
} catch {
75-
lastError = error
7672
try await Task.sleep(for: interval)
7773
}
7874
}
7975

80-
if let lastError {
81-
throw lastError
82-
}
83-
return false
76+
return try await condition()
8477
}
8578

8679
extension FileManager {

0 commit comments

Comments
 (0)