Make async stacktraces less verbose (#21091)

* Name iterators something human readable

Remove intermediate async procs from stacktraces

Clean async traceback message from reraises message

* Remove unused import/variable

* Fix failing tests

Don't add {.stackTrace: off.} to anonymous procs (They already don't appear in stacktrace)

* Fix failing tests in pragma category

Now check that the nim is a routine type first so we don't run into any assertion defects

* Hide stack trace pragma in docs and update doc tests

User doesn't need to know if something won't appear so this more becomes verbose noise

If this is a bad idea we can always add a `when defined(nimdoc)` switch so we don't add {.stackTrace: off.} to the Future[T] returning proc for docs
This commit is contained in:
Jake Leahy 2022-12-16 02:05:34 +11:00 • committed by GitHub
commit d88f46df38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 63 deletions

View file

@ -67,51 +67,22 @@ import re
const expected = """
b failure
Async traceback:
tasync_traceback\.nim\(\d+?\)\s+?tasync_traceback
asyncmacro\.nim\(\d+?\)\s+?a
asyncmacro\.nim\(\d+?\)\s+?aNimAsyncContinue
## Resumes an async procedure
tasync_traceback\.nim\(\d+?\)\s+?aIter
asyncmacro\.nim\(\d+?\)\s+?b
asyncmacro\.nim\(\d+?\)\s+?bNimAsyncContinue
## Resumes an async procedure
tasync_traceback\.nim\(\d+?\)\s+?bIter
#\[
tasync_traceback\.nim\(\d+?\)\s+?tasync_traceback
asyncmacro\.nim\(\d+?\)\s+?a
asyncmacro\.nim\(\d+?\)\s+?aNimAsyncContinue
## Resumes an async procedure
asyncmacro\.nim\(\d+?\)\s+?aIter
asyncfutures\.nim\(\d+?\)\s+?read
\]#
tasync_traceback\.nim\(\d+?\) tasync_traceback
tasync_traceback\.nim\(\d+?\) a \(Async\)
tasync_traceback\.nim\(\d+?\) b \(Async\)
Exception message: b failure
bar failure
Async traceback:
tasync_traceback\.nim\(\d+?\)\s+?tasync_traceback
asyncdispatch\.nim\(\d+?\)\s+?waitFor
asyncdispatch\.nim\(\d+?\)\s+?poll
tasync_traceback\.nim\(\d+?\) tasync_traceback
asyncdispatch\.nim\(\d+?\) waitFor
asyncdispatch\.nim\(\d+?\) poll
## Processes asynchronous completion events
asyncdispatch\.nim\(\d+?\)\s+?runOnce
asyncdispatch\.nim\(\d+?\)\s+?processPendingCallbacks
asyncdispatch\.nim\(\d+?\) runOnce
asyncdispatch\.nim\(\d+?\) processPendingCallbacks
## Executes pending callbacks
asyncmacro\.nim\(\d+?\)\s+?barNimAsyncContinue
## Resumes an async procedure
tasync_traceback\.nim\(\d+?\)\s+?barIter
#\[
tasync_traceback\.nim\(\d+?\)\s+?tasync_traceback
asyncdispatch\.nim\(\d+?\)\s+?waitFor
asyncdispatch\.nim\(\d+?\)\s+?poll
## Processes asynchronous completion events
asyncdispatch\.nim\(\d+?\)\s+?runOnce
asyncdispatch\.nim\(\d+?\)\s+?processPendingCallbacks
## Executes pending callbacks
asyncmacro\.nim\(\d+?\)\s+?fooNimAsyncContinue
## Resumes an async procedure
asyncmacro\.nim\(\d+?\)\s+?fooIter
asyncfutures\.nim\(\d+?\)\s+?read
\]#
tasync_traceback\.nim\(\d+?\) bar \(Async\)
Exception message: bar failure
"""