Skip to content

Commit 9917c7c

Browse files
authored
Merge pull request #2056 from ahoppen/task-scheduler-test-relax
Relax the assertion in `testHighPriorityTasksGetExecutedBeforeLowPriorityTasks`
2 parents d645f44 + b358b16 commit 9917c7c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Tests/SemanticIndexTests/TaskSchedulerTests.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ final class TaskSchedulerTests: XCTestCase {
3939
}
4040
},
4141
validate: { (recordings: [Set<TaskID>]) in
42-
// Check that all high-priority tasks start executing before the low-priority tasks
43-
let highPriorityRecordingSlice = recordings.prefix(while: {
44-
$0.isEmpty || $0.contains(where: \.isHighPriority)
42+
// Check that all high-priority tasks start executing before the first low-priority task finishes
43+
var startedLowPriorityTasks: Set<TaskID> = []
44+
let highPriorityRecordingSlice = recordings.prefix(while: { recording in
45+
if startedLowPriorityTasks.contains(where: { !recording.contains($0) }) {
46+
return false
47+
}
48+
startedLowPriorityTasks.formUnion(recording.filter(\.isLowPriority))
49+
return true
4550
})
4651
let taskIdsInHighPriorityRecordingSlice = Set(highPriorityRecordingSlice.flatMap { $0 })
4752
XCTAssert(

0 commit comments

Comments
 (0)