summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-04-02 16:01:23 +0200
committerEmīls <emils@mullvad.net>2024-04-04 13:22:12 +0200
commit8a71b5d2320d3a3d6d226ae827fa70797776b205 (patch)
tree8d791ba12ff041a051de18ac8c64f29e1aa8bcd1
parent7108bfb13eb80edb7dd20f6b32b34511c57c7bc1 (diff)
downloadmullvadvpn-8a71b5d2320d3a3d6d226ae827fa70797776b205.tar.xz
mullvadvpn-8a71b5d2320d3a3d6d226ae827fa70797776b205.zip
Add comments to explain a dummy function used in tests
-rw-r--r--ios/PacketTunnelCoreTests/TaskSleepTests.swift11
1 files changed, 8 insertions, 3 deletions
diff --git a/ios/PacketTunnelCoreTests/TaskSleepTests.swift b/ios/PacketTunnelCoreTests/TaskSleepTests.swift
index b71dc14f10..58768021f3 100644
--- a/ios/PacketTunnelCoreTests/TaskSleepTests.swift
+++ b/ios/PacketTunnelCoreTests/TaskSleepTests.swift
@@ -30,9 +30,9 @@ final class TaskSleepTests: XCTestCase {
/// cancel a `DispatchSourceTimer` in a `Task` trying to call `resume` on its continuation handler more than once
func testSuccessfulEventHandlerRemovesCancellation() async throws {
for _ in 0 ... 20 {
- var task = recoveryTask()
+ let task = recoveryTask()
try await Task.sleep(duration: .milliseconds(10))
- task.doAnythingToSilenceAWarning()
+ task.callDummyFunctionToForceConcurrencyWait()
}
}
@@ -46,5 +46,10 @@ final class TaskSleepTests: XCTestCase {
}
private extension AutoCancellingTask {
- func doAnythingToSilenceAWarning() {}
+ /// This function is here to silence a warning about unused variables in `testSuccessfulEventHandlerRemovesCancellation`
+ /// The following construct `_ = recoveryTask()` cannot be used as the resulting `AutoCancellingTask`
+ /// would immediately get `deinit`ed, changing the test scenario.
+ /// A dummy function is needed to make sure the task is not cancelled before concurrency is forced
+ /// by having a call to `Task.sleep`
+ func callDummyFunctionToForceConcurrencyWait() {}
}