Class: Evilution::Integration::RSpec::ResultBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/integration/rspec/result_builder.rb

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

Instance Method Summary collapse

Instance Method Details

#from_run(status, command, detector, examples_loaded: nil) ⇒ Object

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.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/evilution/integration/rspec/result_builder.rb', line 24

def from_run(status, command, detector, examples_loaded: nil)
  return { passed: true, test_command: command } if status.zero?

  if detector.only_crashes?
    classes = detector.unique_crash_classes
    return {
      passed: false,
      test_crashed: true,
      error: "test crashes: #{detector.crash_summary}",
      error_class: (classes.first if classes.length == 1),
      test_command: command
    }
  end

  # Nonzero exit + zero examples loaded = the spec file did not register any
  # examples (load error, autoload mismatch, etc.), so nothing ran against
  # the mutation. Surfacing this as a generic fail would let classify_status
  # fall through to its :killed default and silently inflate the kill count
  # even though no example ever observed the mutation (EV-720r: macOS Rails
  # users hit autoload / fail_if_no_examples paths that yielded killed=100%
  # with empty worker output). Note: this checks LOADED count, not executed
  # count — filters/skip/--fail-fast can leave loaded > executed, but the
  # "spec failed to load entirely" case is the failure mode this guard targets.
  if !examples_loaded.nil? && examples_loaded.zero?
    return {
      passed: false,
      error: "RSpec exited #{status} but loaded 0 examples — no examples ran against the mutation. " \
             "Likely the spec file failed to load, --spec was misrouted, or RSpec is configured " \
             "with fail_if_no_examples. The mutation cannot be counted as killed.",
      test_command: command
    }
  end

  { passed: false, test_command: command }
end

#unresolved(mutation) ⇒ Object

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.



6
7
8
9
10
11
12
13
# File 'lib/evilution/integration/rspec/result_builder.rb', line 6

def unresolved(mutation)
  {
    passed: false,
    unresolved: true,
    error: "no matching spec resolved for #{mutation.file_path}",
    test_command: "rspec (skipped: no spec resolved for #{mutation.file_path})"
  }
end

#unresolved_example(mutation) ⇒ Object

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.



15
16
17
18
19
20
21
22
# File 'lib/evilution/integration/rspec/result_builder.rb', line 15

def unresolved_example(mutation)
  {
    passed: false,
    unresolved: true,
    error: "no matching example found for #{mutation.file_path}",
    test_command: "rspec (skipped: no matching example for #{mutation.file_path})"
  }
end