Class: Mutant::Reporter::CLI

Inherits:
Mutant::Reporter show all
Defined in:
lib/mutant/reporter/cli.rb

Overview

Reporter that reports in human readable format

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Reporter

#notice

Instance Attribute Details

#ioIO (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return IO stream

Returns:

  • (IO)


153
154
155
# File 'lib/mutant/reporter/cli.rb', line 153

def io
  @io
end

#statsStats (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return stats

Returns:



161
162
163
# File 'lib/mutant/reporter/cli.rb', line 161

def stats
  @stats
end

Instance Method Details

#config(config) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Report config

Parameters:

  • config (Mutant::Config)

Returns:

  • (self)


64
65
66
67
68
69
# File 'lib/mutant/reporter/cli.rb', line 64

def config(config)
  puts 'Mutant configuration:'
  puts "Matcher:   #{config.matcher.inspect}"
  puts "Filter:    #{config.filter.inspect}"
  puts "Strategy:  #{config.strategy.inspect}"
end

#error_streamIO

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return error stream

Returns:

  • (IO)


26
27
28
# File 'lib/mutant/reporter/cli.rb', line 26

def error_stream
  @config.debug? ? io : StringIO.new
end

#errors(errors) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Report errors

Parameters:

Returns:

  • (self)


132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/mutant/reporter/cli.rb', line 132

def errors(errors)
  errors.each do |error|
    failure(error)
  end

  puts
  puts "subjects:   #{stats.subjects}"
  puts "mutations:  #{stats.mutations}"
  puts "noop_fails: #{stats.noop_fails}"
  puts "kills:      #{stats.kills}"
  puts "alive:      #{stats.alive}"
  puts "mtime:      %02.2fs" % stats.time
  puts "rtime:      %02.2fs" % stats.runtime
end

#killer(killer) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Reporter killer

Parameters:

Returns:

  • (self)


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/mutant/reporter/cli.rb', line 105

def killer(killer)
  stats.killer(killer)

  color, word =
    if killer.fail?
      [Color::RED,   'Alive']
    else
      [Color::GREEN, 'Killed']
    end

  print_killer(color, word, killer)

  if killer.fail?
    colorized_diff(killer.mutation)
  end

  self
end

#mutation(mutation) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Report mutation

Parameters:

Returns:

  • (self)


48
49
50
51
52
53
54
# File 'lib/mutant/reporter/cli.rb', line 48

def mutation(mutation)
  if @config.debug?
    colorized_diff(mutation)
  end

  self
end

#noop(killer) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Report noop

Parameters:

Returns:

  • (self)


79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/mutant/reporter/cli.rb', line 79

def noop(killer)
  color, word =
    if killer.fail?
      [Color::GREEN, 'Alive']
    else
      [Color::RED,   'Killed']
    end

  print_killer(color, word, killer)

  unless killer.fail?
    puts(killer.mutation.source)
    stats.noop_fail(killer)
  end

  self
end

#output_streamIO

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return output stream

Returns:

  • (IO)


36
37
38
# File 'lib/mutant/reporter/cli.rb', line 36

def output_stream
  @config.debug? ? io : StringIO.new
end

#subject(subject) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Reporter subject

Parameters:

Returns:

  • (self)


15
16
17
18
# File 'lib/mutant/reporter/cli.rb', line 15

def subject(subject)
  stats.subject
  puts("Subject: #{subject.identification}")
end