<commit_before>if RUBY_PLATFORM != "java"
  require 'coveralls'
  Coveralls.wear!
end

require 'sidekiq'
require 'sidekiq/testing'

require 'minitest'
require 'mocha/setup'
require 'rack/test'

require 'sidetiq'
require 'sidetiq/web'
require 'sidetiq/lock/watcher'

class Sidetiq::Supervisor
  def self.clock
    @clock ||= Sidetiq::Clock.new
  end

  def self.handler
    Sidetiq::Handler.new
  end
end

# Keep the test output clean.
Sidetiq.logger = Logger.new(nil)

Dir[File.join(File.dirname(__FILE__), 'fixtures/**/*.rb')].each do |fixture|
  require fixture
end

class Sidekiq::Client
  # Sidekiq testing helper now overwrites raw_push so we need to use
  # raw_push_old below to keep tests as is.
  # https://github.com/mperham/sidekiq/blob/v2.12.4/lib/sidekiq/client.rb#L39
  def self.push_old(item)
    normed = normalize_item(item)
    payload = process_single(item['class'], normed)

    pushed = false
    pushed = raw_push_old([payload]) if payload
    pushed ? payload['jid'] : nil
  end
end

class Sidetiq::TestCase < MiniTest::Test
  def setup
    Sidekiq.redis { |r| r.flushall }
  end

  def clock
    Sidetiq.clock
  end

  # Blatantly stolen from Sidekiq's test suite.
  def add_retry(worker = 'SimpleWorker', jid = 'bob', at = Time.now.to_f)
    payload = Sidekiq.dump_json('class' => worker,
      'args' => [], 'queue' => 'default', 'jid' => jid,
      'retry_count' => 2, 'failed_at' => Time.now.utc)

    Sidekiq.redis do |conn|
      conn.zadd('retry', at.to_s, payload)
    end
  end
end

# Override Celluloid's at_exit hook.
at_exit {
  Minitest.run ARGV
}<commit_msg>Return status code correctly when running tests.<commit_after>if RUBY_PLATFORM != "java"
  require 'coveralls'
  Coveralls.wear!
end

require 'sidekiq'
require 'sidekiq/testing'

require 'minitest'
require 'mocha/setup'
require 'rack/test'

require 'sidetiq'
require 'sidetiq/web'
require 'sidetiq/lock/watcher'

class Sidetiq::Supervisor
  def self.clock
    @clock ||= Sidetiq::Clock.new
  end

  def self.handler
    Sidetiq::Handler.new
  end
end

# Keep the test output clean.
Sidetiq.logger = Logger.new(nil)

Dir[File.join(File.dirname(__FILE__), 'fixtures/**/*.rb')].each do |fixture|
  require fixture
end

class Sidekiq::Client
  # Sidekiq testing helper now overwrites raw_push so we need to use
  # raw_push_old below to keep tests as is.
  # https://github.com/mperham/sidekiq/blob/v2.12.4/lib/sidekiq/client.rb#L39
  def self.push_old(item)
    normed = normalize_item(item)
    payload = process_single(item['class'], normed)

    pushed = false
    pushed = raw_push_old([payload]) if payload
    pushed ? payload['jid'] : nil
  end
end

class Sidetiq::TestCase < MiniTest::Test
  def setup
    Sidekiq.redis { |r| r.flushall }
  end

  def clock
    Sidetiq.clock
  end

  # Blatantly stolen from Sidekiq's test suite.
  def add_retry(worker = 'SimpleWorker', jid = 'bob', at = Time.now.to_f)
    payload = Sidekiq.dump_json('class' => worker,
      'args' => [], 'queue' => 'default', 'jid' => jid,
      'retry_count' => 2, 'failed_at' => Time.now.utc)

    Sidekiq.redis do |conn|
      conn.zadd('retry', at.to_s, payload)
    end
  end
end

# Override Celluloid's at_exit hook manually.
at_exit {
  exit Minitest.run(ARGV) || false
}
{'fraction_non_alphanumeric': 0.12765302983697324, 'fraction_numerical': 0.004306367271608736, 'mean_word_length': 3.6926406926406927, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7436712', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1207, 'n_words': 292}