Class: RSpec::Queue::ReportRunner

Inherits:
Object
  • Object
show all
Includes:
CI::Queue::OutputHelpers, RunnerHelpers
Defined in:
lib/rspec/queue.rb

Instance Method Summary collapse

Instance Method Details

#call(options, stdout, stderr) ⇒ Object



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/rspec/queue.rb', line 272

def call(options, stdout, stderr)
  setup(options, stdout, stderr)

  queue = CI::Queue.from_uri(queue_url, RSpec::Queue.config)

  supervisor = begin
    queue.supervisor
  rescue NotImplementedError => error
    abort! error.message
  end

  step("Waiting for workers to complete")

  unless supervisor.wait_for_workers
    unless supervisor.queue_initialized?
      abort! "No leader was elected. This typically means no worker was able to start. Were there any errors during application boot?"
    end

    unless supervisor.exhausted?
      abort! "#{supervisor.size} tests weren't run."
    end
  end

  errors = supervisor.build.error_reports.sort_by(&:first).map do |_, error_data|
      RSpec::Queue::ErrorReport.load(error_data)
  end
  if errors.empty?
    step(green('No errors found'))
    0
  else
    message = errors.size == 1 ? "1 error found" : "#{errors.size} errors found"
    step(red(message), collapsed: false)

    pretty_print_summary(errors)
    pretty_print_failures(errors)
    1
    # Example output
    #
    # FAILED TESTS SUMMARY:
    # =================================================================================
    #   ./spec/dummy_spec.rb
    #   ./spec/dummy_spec_2.rb (2 failures)
    #   ./spec/dummy_spec_3.rb (3 failures)
    # =================================================================================
    #
    # --------------------------------------------------------------------------------
    # Error 1 of 3
    # --------------------------------------------------------------------------------
    #
    #   Object doesn't work on first try
    #   Failure/Error: expect(1 + 1).to be == 42
    #
    #     expected: == 42
    #      got:    2
    #
    # --- stacktrace will be here ---
    # --- rerun command will be here ---
    #
    # --------------------------------------------------------------------------------
    # Error 2 of 3
    # --------------------------------------------------------------------------------
    #
    #   Object doesn't work on first try
    #   Failure/Error: expect(1 + 1).to be == 42
    #
    #     expected: == 42
    #      got:    2
    #
    # --- stacktrace will be here ---
    # --- rerun command will be here ---
    #
    #  ... etc
    # =================================================================================
  end
end