File tree Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Expand file tree Collapse file tree 1 file changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,7 @@ def time_it
73
73
74
74
timeout = ENV . fetch ( "TEST_TIMEOUT" , 10 ) . to_i
75
75
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
81
77
end
82
78
ensure
83
79
self . time = Minitest . clock_time - t0
@@ -86,20 +82,33 @@ def time_it
86
82
87
83
88
84
module DebugSlowTests
89
- def enable_extension! ( ...)
85
+ def wrap_the_thing ( name )
86
+ rv = nil
90
87
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
93
101
end
94
102
95
103
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
99
107
end
100
108
end
101
109
102
110
111
+
103
112
module ActiveRecord
104
113
class TestCase
105
114
include TestTimeoutHelper
You can’t perform that action at this time.
0 commit comments