2015-12-31 18:33:35 -05:00
|
|
|
# frozen_string_literal: true
|
2013-05-10 23:43:53 -04:00
|
|
|
$TESTING = true
|
2015-10-21 12:29:58 -04:00
|
|
|
# disable minitest/parallel threads
|
|
|
|
ENV["N"] = "0"
|
|
|
|
|
2015-07-10 15:35:02 -04:00
|
|
|
if ENV["COVERAGE"]
|
2012-01-24 01:07:21 -05:00
|
|
|
require 'simplecov'
|
2013-04-12 16:57:24 -04:00
|
|
|
SimpleCov.start do
|
|
|
|
add_filter "/test/"
|
2014-02-01 18:04:20 -05:00
|
|
|
add_filter "/myapp/"
|
2013-04-12 16:57:24 -04:00
|
|
|
end
|
2012-01-24 01:07:21 -05:00
|
|
|
end
|
2015-07-10 15:35:02 -04:00
|
|
|
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
|
2012-01-24 01:07:21 -05:00
|
|
|
|
2017-01-03 18:41:48 -05:00
|
|
|
trap 'TSTP' do
|
2015-10-06 15:43:01 -04:00
|
|
|
threads = Thread.list
|
|
|
|
|
|
|
|
puts
|
|
|
|
puts "=" * 80
|
2017-01-03 18:41:48 -05:00
|
|
|
puts "Received TSTP signal; printing all #{threads.count} thread backtraces."
|
2015-10-06 15:43:01 -04:00
|
|
|
|
|
|
|
threads.each do |thr|
|
|
|
|
description = thr == Thread.main ? "Main thread" : thr.inspect
|
|
|
|
puts
|
|
|
|
puts "#{description} backtrace: "
|
|
|
|
puts thr.backtrace.join("\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "=" * 80
|
|
|
|
end
|
|
|
|
|
2012-11-01 19:08:27 -04:00
|
|
|
begin
|
2014-11-12 11:22:49 -05:00
|
|
|
require 'pry-byebug'
|
2012-11-01 19:08:27 -04:00
|
|
|
rescue LoadError
|
|
|
|
end
|
2012-09-04 01:38:45 -04:00
|
|
|
|
2012-01-21 19:42:21 -05:00
|
|
|
require 'minitest/autorun'
|
2012-02-14 12:00:26 -05:00
|
|
|
|
2012-03-14 00:19:46 -04:00
|
|
|
require 'sidekiq'
|
2012-02-14 12:00:26 -05:00
|
|
|
require 'sidekiq/util'
|
2012-05-15 22:44:35 -04:00
|
|
|
Sidekiq.logger.level = Logger::ERROR
|
2012-03-14 00:19:46 -04:00
|
|
|
|
2014-05-13 13:06:27 -04:00
|
|
|
Sidekiq::Test = Minitest::Test
|
2013-09-22 17:38:33 -04:00
|
|
|
|
2012-03-14 00:19:46 -04:00
|
|
|
require 'sidekiq/redis_connection'
|
2014-06-07 23:44:35 -04:00
|
|
|
REDIS_URL = ENV['REDIS_URL'] || 'redis://localhost/15'
|
2017-03-24 14:01:45 -04:00
|
|
|
REDIS = Sidekiq::RedisConnection.create(:url => REDIS_URL)
|
2013-05-02 03:47:56 -04:00
|
|
|
|
|
|
|
Sidekiq.configure_client do |config|
|
2017-03-24 14:01:45 -04:00
|
|
|
config.redis = { :url => REDIS_URL }
|
2013-05-02 03:47:56 -04:00
|
|
|
end
|
2015-07-12 13:51:34 -04:00
|
|
|
|
|
|
|
def capture_logging(lvl=Logger::INFO)
|
|
|
|
old = Sidekiq.logger
|
|
|
|
begin
|
|
|
|
out = StringIO.new
|
|
|
|
logger = Logger.new(out)
|
|
|
|
logger.level = lvl
|
|
|
|
Sidekiq.logger = logger
|
|
|
|
yield
|
|
|
|
out.string
|
|
|
|
ensure
|
|
|
|
Sidekiq.logger = old
|
|
|
|
end
|
|
|
|
end
|
2015-10-21 12:29:58 -04:00
|
|
|
|
|
|
|
def with_logging(lvl=Logger::DEBUG)
|
|
|
|
old = Sidekiq.logger.level
|
|
|
|
begin
|
|
|
|
Sidekiq.logger.level = lvl
|
|
|
|
yield
|
|
|
|
ensure
|
|
|
|
Sidekiq.logger.level = old
|
|
|
|
end
|
|
|
|
end
|