Skip to content

Commit 86d13fb

Browse files
committed
Fix a non-deterministic test failure in the task scheduler
We were calling `TaskScheduler.schedule` inside a `Task` in `TaskSchedulerTests`. This means that Swift concurrency could re-order the execution of those tasks and thus change the order in which tasks were enqueued to the `TaskScheduler`. Caused by ahoppen@e295a4e#diff-6a451b3244d65ded9386e2816360b7b1debbe6a519e3795d2046c7dbefa7a7d7R351
1 parent 814f3c5 commit 86d13fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Tests/SKCoreTests/TaskSchedulerTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ final class TaskSchedulerTests: XCTestCase {
195195
}
196196
)
197197
}
198-
199198
}
200199

201200
// MARK: - Test helpers
@@ -354,8 +353,9 @@ fileprivate extension TaskScheduler<ClosureTaskDescription> {
354353
body,
355354
dependencies: dependencies
356355
)
356+
let queuedTask = await self.schedule(priority: priority, taskDescription)
357357
return Task(priority: priority) {
358-
await self.schedule(priority: priority, taskDescription).waitToFinishPropagatingCancellation()
358+
await queuedTask.waitToFinishPropagatingCancellation()
359359
}
360360
}
361361
}

0 commit comments

Comments
 (0)