Class: Minitest::Distributed::Reporters::DistributedPogressReporter

Inherits:
Reporter
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/minitest/distributed/reporters/distributed_progress_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, options) ⇒ DistributedPogressReporter

Returns a new instance of DistributedPogressReporter.



16
17
18
19
20
21
22
23
24
# File 'lib/minitest/distributed/reporters/distributed_progress_reporter.rb', line 16

def initialize(io, options)
  super
  if io.tty?
    io.sync = true
  end
  @coordinator = T.let(options[:distributed].coordinator, Coordinators::CoordinatorInterface)
  @window_line_width = T.let(nil, T.nilable(Integer))
  @show_progress = T.let(options[:distributed].progress, T::Boolean)
end

Instance Attribute Details

#coordinatorObject (readonly)

Returns the value of attribute coordinator.



13
14
15
# File 'lib/minitest/distributed/reporters/distributed_progress_reporter.rb', line 13

def coordinator
  @coordinator
end

Instance Method Details

#prerecord(klass, name) ⇒ Object



40
41
42
43
44
45
# File 'lib/minitest/distributed/reporters/distributed_progress_reporter.rb', line 40

def prerecord(klass, name)
  if show_progress?
    clear_current_line
    io.print("[#{results.acks}/#{results.size}] #{klass}##{name}".slice(0...window_line_width))
  end
end

#record(result) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/minitest/distributed/reporters/distributed_progress_reporter.rb', line 48

def record(result)
  clear_current_line if show_progress?

  case (result_type = ResultType.of(result))
  when ResultType::Passed
    # TODO: warn for tests that are slower than the test timeout.
  when ResultType::Skipped, ResultType::Discarded
    io.puts("#{result}\n") if options[:verbose]
  when ResultType::Error, ResultType::Failed, ResultType::Requeued
    io.puts("#{result}\n")
  else
    T.absurd(result_type)
  end
end

#reportObject



64
65
66
# File 'lib/minitest/distributed/reporters/distributed_progress_reporter.rb', line 64

def report
  clear_current_line if show_progress?
end

#startObject



27
28
29
30
# File 'lib/minitest/distributed/reporters/distributed_progress_reporter.rb', line 27

def start
  Signal.trap("WINCH") { @window_line_width = nil }
  super
end