mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Sloppily handle deferred operations
This commit is contained in:
parent
078058ad05
commit
82e13f5434
1 changed files with 11 additions and 5 deletions
|
@ -58,9 +58,9 @@ module Spectator
|
||||||
# Runs test code and produces a result based on the outcome.
|
# Runs test code and produces a result based on the outcome.
|
||||||
# The test code should be called from within the block given to this method.
|
# The test code should be called from within the block given to this method.
|
||||||
def run : Result
|
def run : Result
|
||||||
outcome = capture { yield }
|
elapsed, error = capture { yield }
|
||||||
run_deferred # TODO: Handle errors in deferred blocks.
|
elapsed2, error2 = run_deferred
|
||||||
translate(*outcome)
|
translate(elapsed + elapsed2, error || error2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def report(expectation : Expectation) : Nil
|
def report(expectation : Expectation) : Nil
|
||||||
|
@ -105,9 +105,15 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
# Runs all deferred blocks.
|
# Runs all deferred blocks.
|
||||||
private def run_deferred : Nil
|
private def run_deferred
|
||||||
@deferred.each(&.call)
|
error = nil.as(Exception?)
|
||||||
|
elapsed = Time.measure do
|
||||||
|
@deferred.each(&.call)
|
||||||
|
rescue ex
|
||||||
|
error = ex
|
||||||
|
end
|
||||||
@deferred.clear
|
@deferred.clear
|
||||||
|
{elapsed, error}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue