Class: Rfc::Rif

Inherits:
RSpec::Core::Formatters::BaseTextFormatter
  • Object
show all
Includes:
Shared::BriefPending
Defined in:
lib/rfc/rif.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Shared::BriefPending

#dump_pending

Class Attribute Details

.heartbeat_intervalObject

Returns the value of attribute heartbeat_interval.



17
18
19
# File 'lib/rfc/rif.rb', line 17

def heartbeat_interval
  @heartbeat_interval
end

.output_object_space_statsObject

ObjectSpace statistics are generally not available on JRuby: RuntimeError (ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable)



21
22
23
# File 'lib/rfc/rif.rb', line 21

def output_object_space_stats
  @output_object_space_stats
end

.output_system_loadObject

Returns the value of attribute output_system_load.



23
24
25
# File 'lib/rfc/rif.rb', line 23

def output_system_load
  @output_system_load
end

Instance Attribute Details

#completed_countObject (readonly)

Returns the value of attribute completed_count.



14
15
16
# File 'lib/rfc/rif.rb', line 14

def completed_count
  @completed_count
end

#failed_countObject (readonly)

Returns the value of attribute failed_count.



14
15
16
# File 'lib/rfc/rif.rb', line 14

def failed_count
  @failed_count
end

#passed_countObject (readonly)

Returns the value of attribute passed_count.



14
15
16
# File 'lib/rfc/rif.rb', line 14

def passed_count
  @passed_count
end

#total_countObject (readonly)

Returns the value of attribute total_count.



14
15
16
# File 'lib/rfc/rif.rb', line 14

def total_count
  @total_count
end

Instance Method Details

#dump_failures(notification) ⇒ Object



93
94
# File 'lib/rfc/rif.rb', line 93

def dump_failures(notification)
end

#example_failed(notification) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/rfc/rif.rb', line 53

def example_failed(notification)
  @failed_count += 1
  @completed_count += 1

  output.puts notification.fully_formatted(failed_count)
  output.puts
end

#example_passed(_notification) ⇒ Object



41
42
43
44
45
# File 'lib/rfc/rif.rb', line 41

def example_passed(_notification)
  @passed_count += 1
  @completed_count += 1
  report_progress
end

#example_pending(notification) ⇒ Object



47
48
49
50
51
# File 'lib/rfc/rif.rb', line 47

def example_pending(notification)
  @pending_count += 1
  @completed_count += 1
  report_progress
end

#report_progressObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/rfc/rif.rb', line 61

def report_progress
  if total_count == 0
    # When a test suite has no examples or they are all filtered out,
    # there is no meaningful progress to report.
    return
  end

  this_percent = @completed_count * 100 / total_count
  if @reported_percent != this_percent || @reported_at.nil? ||
    Time.now-@reported_at > self.class.heartbeat_interval
  then
    progress_msg = %Q`\
#{Time.now.strftime('[%Y-%m-%d %H:%M:%S %z]')} \
#{this_percent}% (#{@completed_count}/#{@total_count} examples) complete`
    if @pending_count > 0
      progress_msg += ", #{@pending_count} pending"
    end
    if @failed_count > 0
      progress_msg += ", #{@failed_count} failed"
    end
    if self.class.output_object_space_stats
      progress_msg += "; objects: #{ObjectSpace.count_objects[:TOTAL]} total, #{ObjectSpace.count_objects[:FREE]} free"
    end
    if self.class.output_system_load
      progress_msg += "\n#{system_load_msg}"
    end
    output.puts progress_msg
    @reported_percent = this_percent
    @reported_at = Time.now
  end
end

#start(notification) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rfc/rif.rb', line 27

def start(notification)
  @total_count = notification.count
  @passed_count = 0
  @pending_count = 0
  @failed_count = 0
  @completed_count = 0
  @this_percent = 0
  @started_at = Time.now

  # There is no progress at this point but report the total number of
  # examples prior to running any of them
  report_progress
end