mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 20:04:18 +00:00
Use regex to match output of tasync_traceback.
This commit is contained in:
@@ -1,61 +1,6 @@
|
||||
discard """
|
||||
exitcode: 0
|
||||
disabled: "windows"
|
||||
output: '''
|
||||
b failure
|
||||
Async traceback:
|
||||
tasync_traceback.nim(97) tasync_traceback
|
||||
asyncmacro.nim(395) a
|
||||
asyncmacro.nim(34) a_continue
|
||||
## Resumes an async procedure
|
||||
tasync_traceback.nim(95) aIter
|
||||
asyncmacro.nim(395) b
|
||||
asyncmacro.nim(34) b_continue
|
||||
## Resumes an async procedure
|
||||
tasync_traceback.nim(92) bIter
|
||||
#[
|
||||
tasync_traceback.nim(97) tasync_traceback
|
||||
asyncmacro.nim(395) a
|
||||
asyncmacro.nim(43) a_continue
|
||||
## Resumes an async procedure
|
||||
asyncfutures.nim(211) callback=
|
||||
asyncfutures.nim(190) addCallback
|
||||
asyncfutures.nim(53) callSoon
|
||||
asyncmacro.nim(34) a_continue
|
||||
## Resumes an async procedure
|
||||
asyncmacro.nim(0) aIter
|
||||
asyncfutures.nim(304) read
|
||||
]#
|
||||
Exception message: b failure
|
||||
Exception type:
|
||||
|
||||
bar failure
|
||||
Async traceback:
|
||||
tasync_traceback.nim(113) tasync_traceback
|
||||
asyncdispatch.nim(1492) waitFor
|
||||
asyncdispatch.nim(1496) poll
|
||||
## Processes asynchronous completion events
|
||||
asyncdispatch.nim(1262) runOnce
|
||||
asyncdispatch.nim(183) processPendingCallbacks
|
||||
## Executes pending callbacks
|
||||
asyncmacro.nim(34) bar_continue
|
||||
## Resumes an async procedure
|
||||
tasync_traceback.nim(108) barIter
|
||||
#[
|
||||
tasync_traceback.nim(113) tasync_traceback
|
||||
asyncdispatch.nim(1492) waitFor
|
||||
asyncdispatch.nim(1496) poll
|
||||
## Processes asynchronous completion events
|
||||
asyncdispatch.nim(1262) runOnce
|
||||
asyncdispatch.nim(183) processPendingCallbacks
|
||||
## Executes pending callbacks
|
||||
asyncmacro.nim(34) foo_continue
|
||||
## Resumes an async procedure
|
||||
asyncmacro.nim(0) fooIter
|
||||
asyncfutures.nim(304) read
|
||||
]#
|
||||
Exception message: bar failure
|
||||
Exception type:'''
|
||||
"""
|
||||
import asyncdispatch
|
||||
|
||||
@@ -87,6 +32,8 @@ import asyncdispatch
|
||||
# tasync_traceback.nim(21) a
|
||||
# tasync_traceback.nim(18) b
|
||||
|
||||
var result = ""
|
||||
|
||||
proc b(): Future[int] {.async.} =
|
||||
if true:
|
||||
raise newException(OSError, "b failure")
|
||||
@@ -98,8 +45,8 @@ let aFut = a()
|
||||
try:
|
||||
discard waitFor aFut
|
||||
except Exception as exc:
|
||||
echo exc.msg
|
||||
echo()
|
||||
result.add(exc.msg & "\n")
|
||||
result.add("\n")
|
||||
|
||||
# From #6803
|
||||
proc bar(): Future[string] {.async.} =
|
||||
@@ -110,7 +57,69 @@ proc bar(): Future[string] {.async.} =
|
||||
proc foo(): Future[string] {.async.} = return await bar()
|
||||
|
||||
try:
|
||||
echo waitFor(foo())
|
||||
result.add(waitFor(foo()) & "\n")
|
||||
except Exception as exc:
|
||||
echo exc.msg
|
||||
echo()
|
||||
result.add(exc.msg & "\n")
|
||||
result.add("\n")
|
||||
|
||||
# Use re to parse the result
|
||||
import re
|
||||
const expected = """
|
||||
b failure
|
||||
Async traceback:
|
||||
tasync_traceback\.nim\(\d+?\)\s+?tasync_traceback
|
||||
asyncmacro\.nim\(\d+?\)\s+?a
|
||||
asyncmacro\.nim\(\d+?\)\s+?a_continue
|
||||
## Resumes an async procedure
|
||||
tasync_traceback\.nim\(\d+?\)\s+?aIter
|
||||
asyncmacro\.nim\(\d+?\)\s+?b
|
||||
asyncmacro\.nim\(\d+?\)\s+?b_continue
|
||||
## 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+?a_continue
|
||||
## Resumes an async procedure
|
||||
asyncmacro\.nim\(\d+?\)\s+?aIter
|
||||
asyncfutures\.nim\(\d+?\)\s+?read
|
||||
\]#
|
||||
Exception message: b failure
|
||||
Exception type:
|
||||
|
||||
bar failure
|
||||
Async traceback:
|
||||
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+?bar_continue
|
||||
## 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+?foo_continue
|
||||
## Resumes an async procedure
|
||||
asyncmacro\.nim\(\d+?\)\s+?fooIter
|
||||
asyncfutures\.nim\(\d+?\)\s+?read
|
||||
\]#
|
||||
Exception message: bar failure
|
||||
Exception type:
|
||||
"""
|
||||
|
||||
if result.match(re(expected)):
|
||||
echo("Matched")
|
||||
else:
|
||||
echo("Not matched!")
|
||||
echo()
|
||||
echo(result)
|
||||
quit(QuitFailure)
|
||||
|
||||
Reference in New Issue
Block a user