Skip to content

Commit

Permalink
closer
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Sep 5, 2024
1 parent 342fcb2 commit 4951a6b
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,41 +81,41 @@ def time_it
end


module DebugSlowTests
def wrap_the_thing(name)
rv = nil
t0 = Minitest.clock_time
profile = StackProf.run(mode: :wall, interval: 1000) do
rv = yield
end
puts
puts "#{name} took #{Minitest.clock_time - t0} seconds"
puts
pp SpatialModel.lease_connection.instance_variable_get(:@raw_connection).conninfo_hash
puts
StackProf::Report.new(profile).print_text
rv
end
def enable_extension!(...)
wrap_the_thing(__method__) do
super
end
end

def disable_extension!(...)
wrap_the_thing(__method__) do
super
end
end
end
# module DebugSlowTests
# def wrap_the_thing(name)
# rv = nil
# t0 = Minitest.clock_time
# profile = StackProf.run(mode: :wall, interval: 1000) do
# rv = yield
# end
# puts
# puts "#{name} took #{Minitest.clock_time - t0} seconds"
# puts
# pp SpatialModel.lease_connection.instance_variable_get(:@raw_connection).conninfo_hash
# puts
# StackProf::Report.new(profile).print_text
# rv
# end
# def enable_extension!(...)
# wrap_the_thing(__method__) do
# super
# end
# end

# def disable_extension!(...)
# wrap_the_thing(__method__) do
# super
# end
# end
# end



module ActiveRecord
class TestCase
include TestTimeoutHelper
include DebugSlowTests
extend DebugSlowTests
# include DebugSlowTests
# extend DebugSlowTests

def factory(srid: 3785)
RGeo::Cartesian.preferred_factory(srid: srid)
Expand Down Expand Up @@ -164,4 +164,19 @@ def reset
end
end

module DebugResolve
def resolve_hosts(iopts)
host = iopts[:host]
host = host[0, 97] + "..." if host.length > 100
puts "resolve_hosts, hosts: #{host.inspect}"

port = iopts[:port]
port = port[0, 97] + "..." if port.length > 100
puts "resolve_hosts, ports: #{port.inspect}"

super
end
end

PG::Connection.prepend(DebugReset)
PG::Connection.singleton_class.prepend(DebugResolve)

0 comments on commit 4951a6b

Please sign in to comment.