Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/app_profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def run(*args, backend: nil, **kwargs, &block)
)
end
yield
nil # no profile result
ensure
self.backend = original_backend if backend
ProfileId::Current.reset
Expand Down
11 changes: 11 additions & 0 deletions test/app_profiler/run_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ class RunTest < TestCase
assert_operator profile.duration, :>=, 0.1
end

test ".run runs the block but does not return its result when the backend raises" do
ran = false
result = AppProfiler.run(backend: "not a real backend") do
ran = true
:block_value
end

assert(ran)
assert_nil(result)
end

test ".run sets the backend then returns to the previous value" do
orig_backend = AppProfiler.backend
skip("Vernier not supported") unless AppProfiler.vernier_supported?
Expand Down
Loading