File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
lib/buildkite/test_collector/library_hooks Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 2323 # The _buildkite prefix here is added as a safeguard against name collisions
2424 # as we are in the main thread
2525 Thread . current [ :_buildkite_tracer ] = tracer
26- example . run
27- Thread . current [ :_buildkite_tracer ] = nil
28-
29- tracer . finalize
30-
31- trace = Buildkite ::TestCollector ::RSpecPlugin ::Trace . new ( example , history : tracer . history )
32- Buildkite ::TestCollector . uploader . traces [ example . id ] = trace
26+ # It's important to use begin/ensure here, because otherwise if other hooks fail,
27+ # the cleanup code won't run, meaning we will miss some data.
28+ #
29+ # Having said that, this behavior isn't documented by RSpec.
30+ begin
31+ example . run
32+ ensure
33+ Thread . current [ :_buildkite_tracer ] = nil
34+
35+ tracer . finalize
36+
37+ trace = Buildkite ::TestCollector ::RSpecPlugin ::Trace . new ( example , history : tracer . history )
38+ Buildkite ::TestCollector . uploader . traces [ example . id ] = trace
39+ end
3340 end
3441
3542 config . after ( :suite ) do
You can’t perform that action at this time.
0 commit comments