Use regex to match output of tasync_traceback.
This commit is contained in:
parent
2312f71819
commit
b7713859ab
1 changed files with 69 additions and 60 deletions
|
|
@ -1,61 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
exitcode: 0
|
exitcode: 0
|
||||||
disabled: "windows"
|
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
|
import asyncdispatch
|
||||||
|
|
||||||
|
|
@ -87,6 +32,8 @@ import asyncdispatch
|
||||||
# tasync_traceback.nim(21) a
|
# tasync_traceback.nim(21) a
|
||||||
# tasync_traceback.nim(18) b
|
# tasync_traceback.nim(18) b
|
||||||
|
|
||||||
|
var result = ""
|
||||||
|
|
||||||
proc b(): Future[int] {.async.} =
|
proc b(): Future[int] {.async.} =
|
||||||
if true:
|
if true:
|
||||||
raise newException(OSError, "b failure")
|
raise newException(OSError, "b failure")
|
||||||
|
|
@ -98,8 +45,8 @@ let aFut = a()
|
||||||
try:
|
try:
|
||||||
discard waitFor aFut
|
discard waitFor aFut
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
echo exc.msg
|
result.add(exc.msg & "\n")
|
||||||
echo()
|
result.add("\n")
|
||||||
|
|
||||||
# From #6803
|
# From #6803
|
||||||
proc bar(): Future[string] {.async.} =
|
proc bar(): Future[string] {.async.} =
|
||||||
|
|
@ -110,7 +57,69 @@ proc bar(): Future[string] {.async.} =
|
||||||
proc foo(): Future[string] {.async.} = return await bar()
|
proc foo(): Future[string] {.async.} = return await bar()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
echo waitFor(foo())
|
result.add(waitFor(foo()) & "\n")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
echo exc.msg
|
result.add(exc.msg & "\n")
|
||||||
echo()
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue