diff --git a/tests/profiler/testevents.nim b/tests/profiler/testevents.nim index 69caef7..86c21f7 100644 --- a/tests/profiler/testevents.nim +++ b/tests/profiler/testevents.nim @@ -107,4 +107,28 @@ suite "profiler hooks test suite": SimpleEvent(state: ExtendedFutureState.Running, procedure: "withChildren"), SimpleEvent(state: ExtendedFutureState.Running, procedure: "segment 2"), SimpleEvent(state: ExtendedFutureState.Completed, procedure: "withChildren"), - ] \ No newline at end of file + ] + + test "should not say a future is completed before children in finally blocks are run": + skip() + when false: + # TODO: chronos allows completed futures to generate children in their + # finally blocks. This causes a set of transitions that break our state + # machine. + proc withFinally(): Future[void] {.async.} = + try: + return + finally: + await sleepAsync(10.milliseconds) + + waitFor withFinally() + + check recording == @[ + SimpleEvent(state: Pending, procedure: "withFinally"), + SimpleEvent(state: ExtendedFutureState.Running, procedure: "withFinally"), + SimpleEvent(state: ExtendedFutureState.Pending, procedure: "chronos.sleepAsync(Duration)"), + SimpleEvent(state: ExtendedFutureState.Paused, procedure: "withFinally"), + SimpleEvent(state: ExtendedFutureState.Completed, procedure: "chronos.sleepAsync(Duration)"), + SimpleEvent(state: ExtendedFutureState.Running, procedure: "withFinally"), + SimpleEvent(state: ExtendedFutureState.Completed, procedure: "withFinally") + ]