Class: Henitai::Reporter::DryRun
- Inherits:
-
Base
- Object
- Base
- Henitai::Reporter::DryRun
show all
- Defined in:
- lib/henitai/reporter.rb,
sig/henitai.rbs
Overview
Dry-run listing: prints the post-filter mutant set (Gates 0–3) without
any execution results. Used internally by the runner for --dry-run;
not part of the reporters: configuration surface.
Instance Attribute Summary collapse
Attributes inherited from Base
#config, #history_store
Instance Method Summary
collapse
Methods inherited from Base
#authoritative?, #canonical_path
Constructor Details
#initialize(config:, history_store: nil, io: $stdout) ⇒ DryRun
Returns a new instance of DryRun.
461
462
463
464
|
# File 'lib/henitai/reporter.rb', line 461
def initialize(config:, history_store: nil, io: $stdout)
super(config:, history_store:)
@io = io
end
|
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
472
473
474
|
# File 'lib/henitai/reporter.rb', line 472
def io
@io
end
|
Instance Method Details
#grouped_lines(mutants) ⇒ Array[String]
481
482
483
484
485
|
# File 'lib/henitai/reporter.rb', line 481
def grouped_lines(mutants)
mutants.group_by { |mutant| subject_label(mutant) }.flat_map do |label, subject_mutants|
["", label] + subject_mutants.map { |mutant| mutant_line(mutant) }
end
end
|
#ignore_reason_for(mutant) ⇒ String?
507
508
509
510
511
512
|
# File 'lib/henitai/reporter.rb', line 507
def ignore_reason_for(mutant)
return nil unless mutant.respond_to?(:ignore_reason)
reason = mutant.ignore_reason
reason ? "(#{reason})" : nil
end
|
#listing_lines(mutants) ⇒ Array[String]
474
475
476
477
478
479
|
# File 'lib/henitai/reporter.rb', line 474
def listing_lines(mutants)
= ["Dry run: #{mutants.size} mutants (no mutants executed)"]
return + ["", summary_line(mutants)] if mutants.empty?
+ grouped_lines(mutants) + ["", summary_line(mutants)]
end
|
#mutant_line(mutant) ⇒ String
494
495
496
497
498
499
500
501
502
503
504
505
|
# File 'lib/henitai/reporter.rb', line 494
def mutant_line(mutant)
line = format(
" %<operator>s — %<description>s %<file>s:%<line>d [%<status>s]",
operator: mutant.operator,
description: mutant.description,
file: mutant.location.fetch(:file),
line: mutant.location.fetch(:start_line),
status: mutant.status
)
reason = ignore_reason_for(mutant)
reason ? "#{line} #{reason}" : line
end
|
#report(result) ⇒ void
This method returns an undefined value.
466
467
468
|
# File 'lib/henitai/reporter.rb', line 466
def report(result)
io.puts(listing_lines(result.mutants))
end
|
#subject_label(mutant) ⇒ String
487
488
489
490
491
492
|
# File 'lib/henitai/reporter.rb', line 487
def subject_label(mutant)
subject = mutant.subject
return subject.expression if subject.respond_to?(:expression) && subject.expression
mutant.location.fetch(:file, "(unknown subject)")
end
|
#summary_line(mutants) ⇒ String
514
515
516
517
518
|
# File 'lib/henitai/reporter.rb', line 514
def summary_line(mutants)
counts = mutants.group_by(&:status).transform_values(&:size)
summary = counts.map { |status, count| "#{status} #{count}" }.join(" | ")
"Summary: #{summary.empty? ? 'no mutants' : summary}"
end
|