Skip to content

Commit 3be96f9

Browse files
committed
enable_ext stackprof
1 parent 5fd9f6c commit 3be96f9

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

test/test_helper.rb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ def time_it
7373

7474
timeout = ENV.fetch("TEST_TIMEOUT", 10).to_i
7575
Timeout.timeout(timeout, Timeout::Error, "Test took over #{timeout} seconds to finish") do
76-
profile = StackProf.run(mode: :wall, interval: 1000) do
77-
yield
78-
end
79-
puts
80-
StackProf::Report.new(profile).print_text
76+
yield
8177
end
8278
ensure
8379
self.time = Minitest.clock_time - t0
@@ -86,20 +82,33 @@ def time_it
8682

8783

8884
module DebugSlowTests
89-
def enable_extension!(...)
85+
def wrap_the_thing(name)
86+
rv = nil
9087
t0 = Minitest.clock_time
91-
super
92-
puts "enable_extension! took #{Minitest.clock_time - t0} seconds"
88+
profile = StackProf.run(mode: :wall, interval: 1000) do
89+
rv = yield
90+
end
91+
puts
92+
puts "#{name} took #{Minitest.clock_time - t0} seconds"
93+
puts
94+
StackProf::Report.new(profile).print_text
95+
rv
96+
end
97+
def enable_extension!(...)
98+
wrap_the_thing(__method__) do
99+
super
100+
end
93101
end
94102

95103
def disable_extension!(...)
96-
t0 = Minitest.clock_time
97-
super
98-
puts "disable_extension! took #{Minitest.clock_time - t0} seconds"
104+
wrap_the_thing(__method__) do
105+
super
106+
end
99107
end
100108
end
101109

102110

111+
103112
module ActiveRecord
104113
class TestCase
105114
include TestTimeoutHelper

0 commit comments

Comments
 (0)