Class: Minitest::Reporters::RedisReporter::Worker

Inherits:
Base
  • Object
show all
Defined in:
lib/minitest/reporters/redis_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#completed?, #error_reports, #processed, #total

Constructor Details

#initialize(worker_id:, **options) ⇒ Worker

Returns a new instance of Worker.



153
154
155
156
157
158
159
160
# File 'lib/minitest/reporters/redis_reporter.rb', line 153

def initialize(worker_id:, **options)
  super
  @worker_id = worker_id
  self.failures = 0
  self.errors = 0
  self.skips = 0
  self.requeues = 0
end

Instance Attribute Details

#requeues ⇒ Object

Returns the value of attribute requeues.



151
152
153
# File 'lib/minitest/reporters/redis_reporter.rb', line 151

def requeues
  @requeues
end

Instance Method Details

#record(test) ⇒ Object



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/minitest/reporters/redis_reporter.rb', line 166

def record(test)
  super

  self.total_time = Minitest.clock_time - start_time
  if test.requeued?
    self.requeues += 1
  elsif test.skipped?
    self.skips += 1
  elsif test.error?
    self.errors += 1
  elsif test.failure
    self.failures += 1
  end

  redis.multi do
    if (test.failure || test.error?) && !test.skipped?
      redis.hset(key('error-reports'), "#{test.class}##{test.name}", dump(test))
    else
      redis.hdel(key('error-reports'), "#{test.class}##{test.name}")
    end
    COUNTERS.each do |counter|
      redis.hset(key(counter), worker_id, send(counter))
    end
  end
end

#report ⇒ Object



162
163
164
# File 'lib/minitest/reporters/redis_reporter.rb', line 162

def report
  # noop
end