Class: Mutineer::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/mutineer/result.rb

Overview

Immutable outcome of running one mutant. Ten distinct states:

killed       - a test failed/errored, so the mutation was caught.
survived     - every test passed, so the mutation went undetected.
error        - the child crashed (unhandled exception), or a Minitest
             run's first failure was a database connection or lock
             error (#296): exit status 2.
timeout      - the parent SIGKILLed a child that overran its wall clock.
skipped      - the mutated source failed to re-parse (invalid); no fork.
no_coverage  - no test exercises the mutated line; not run, not scored.
             Also a mutant on a later line of a multi-line statement
             (#254, #289) whose tests ran and did not kill it, when a
             probe on the mutated expression did not see it run (#345).
             A survivor the probe saw run is survived, and counts.
uncapturable - the line's would-be covering test errored during capture,
             so coverage was lost. Excluded from the denominator exactly
             like no_coverage, but reported separately: it signals a
             broken harness (a test that failed to run), not a genuine
             coverage gap.
unplaceable  - the strategy cannot load the mutant where the tests call
             it, so it is not run. Under `--strategy redefine` the
             method belongs to a class or module that cannot be named
             statically (for example each class that includes a
             concern), and every method in a concern's `included` or
             `prepended` block is one (#256). Under `--strategy reload`
             only some methods in such a block are: those it cannot
             load into each class that has them (#297; the cases are
             listed in docs/json-schema.md).
             Excluded from the denominator and, unlike uncapturable,
             from the no-verdict gate: nothing is broken.
             `--test-command` runs these mutants.
ran_at_load  - the mutated line ran while the app booted or its class
             loaded. That run happened before the mutant was applied,
             so a test can check a value the original code computed.
             A survivor on such a line, and a line that ran only at
             load, get this status; a kill stays killed. Excluded from
             the denominator and from the no-verdict gate, like
             unplaceable. `--test-command` verifies these mutants.
ignored      - a known-equivalent mutant the user suppressed, via an
             inline `# mutineer:disable-line` comment or a
             `.mutineer.yml` `ignore:` id. A pre-fork classification
             (never run); excluded from the denominator so a strong
             file can reach 100%.

error and skipped are deliberately distinct: skipped is a pre-fork validity failure (counted separately by the reporter), error is a runtime crash. Never conflate them via details string parsing. uncapturable and unplaceable are pre-fork results, and no_coverage and ran_at_load are pre-fork or a reclassified result (JobPlan.selection_verdict, JobPlan.load_verdict): all excluded from the score denominator.

subject, mutation, and id are nil when the Result is built by Isolation/Runner (which only know the outcome); the orchestrator attaches them afterwards via result.with(subject:, mutation:, id:) so the Reporter can render survivor diffs and emit the id. id is the content-based MutantId (it includes the project-relative file path).

kills is nil except in a --matrix run, where a mutant that was forked carries the Kills its child reported. It annotates the verdict and never decides it.

A Result crosses a process boundary only through WorkerPool's Marshal pipe, from a fork back to the process that forked it, so both ends always run the same code. Nothing persists a marshaled Result (reports, baselines and the coverage cache are JSON), so a new field needs no Marshal compatibility.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, details: nil, subject: nil, mutation: nil, id: nil, kills: nil, reason: nil) ⇒ Result

Every field but status defaults to nil. reason is the text a user gave for an ignored mutant, from an inline marker or an ignore: mapping.

Parameters:

  • status (Symbol) —

    the outcome.

  • details (String, nil) (defaults to: nil) —

    error or skip details.

  • subject (Mutineer::Subject, nil) (defaults to: nil) —

    the mutated subject.

  • mutation (Mutineer::Mutation, nil) (defaults to: nil) —

    the mutation.

  • id (String, nil) (defaults to: nil) —

    the stable mutant id.

  • kills (Mutineer::Kills, nil) (defaults to: nil) —

    the matrix row of a --matrix run.

  • reason (String, nil) (defaults to: nil) —

    why an ignored mutant was suppressed.



79
80
81
# File 'lib/mutineer/result.rb', line 79

def initialize(status:, details: nil, subject: nil, mutation: nil, id: nil, kills: nil, reason: nil)
  super
end

Instance Attribute Details

#details ⇒ Object (readonly)

Returns the value of attribute details

Returns:

  • (Object) —

    the current value of details



68
69
70
# File 'lib/mutineer/result.rb', line 68

def details
  @details
end

#id ⇒ Object (readonly)

Returns the value of attribute id

Returns:

  • (Object) —

    the current value of id



68
69
70
# File 'lib/mutineer/result.rb', line 68

def id
  @id
end

#kills ⇒ Object (readonly)

Returns the value of attribute kills

Returns:

  • (Object) —

    the current value of kills



68
69
70
# File 'lib/mutineer/result.rb', line 68

def kills
  @kills
end

#mutation ⇒ Object (readonly)

Returns the value of attribute mutation

Returns:

  • (Object) —

    the current value of mutation



68
69
70
# File 'lib/mutineer/result.rb', line 68

def mutation
  @mutation
end

#reason ⇒ Object (readonly)

Returns the value of attribute reason

Returns:

  • (Object) —

    the current value of reason



68
69
70
# File 'lib/mutineer/result.rb', line 68

def reason
  @reason
end

#status ⇒ Object (readonly)

Returns the value of attribute status

Returns:

  • (Object) —

    the current value of status



68
69
70
# File 'lib/mutineer/result.rb', line 68

def status
  @status
end

#subject ⇒ Object (readonly)

Returns the value of attribute subject

Returns:

  • (Object) —

    the current value of subject



68
69
70
# File 'lib/mutineer/result.rb', line 68

def subject
  @subject
end

Class Method Details

.error(details = nil) ⇒ Mutineer::Result

Builds an error result.

Parameters:

  • details (String, nil) (defaults to: nil) —

    error details.

Returns:



97
# File 'lib/mutineer/result.rb', line 97

def self.error(details = nil) = new(status: :error, details: details, subject: nil, mutation: nil, id: nil)

.ignored ⇒ Mutineer::Result

Builds an ignored result.

Returns:



133
# File 'lib/mutineer/result.rb', line 133

def self.ignored = new(status: :ignored, details: nil, subject: nil, mutation: nil, id: nil)

.killed ⇒ Mutineer::Result

Builds a killed result.

Returns:



86
# File 'lib/mutineer/result.rb', line 86

def self.killed = new(status: :killed, details: nil, subject: nil, mutation: nil, id: nil)

.no_coverage ⇒ Mutineer::Result

Builds a no_coverage result.

Returns:



113
# File 'lib/mutineer/result.rb', line 113

def self.no_coverage = new(status: :no_coverage, details: nil, subject: nil, mutation: nil, id: nil)

.ran_at_load ⇒ Mutineer::Result

Builds a ran_at_load result.

Returns:



128
# File 'lib/mutineer/result.rb', line 128

def self.ran_at_load = new(status: :ran_at_load, details: nil, subject: nil, mutation: nil, id: nil)

.skipped(details = nil) ⇒ Mutineer::Result

Builds a skipped result.

Parameters:

  • details (String, nil) (defaults to: nil) —

    skip details.

Returns:



108
# File 'lib/mutineer/result.rb', line 108

def self.skipped(details = nil) = new(status: :skipped, details: details, subject: nil, mutation: nil, id: nil)

.survived ⇒ Mutineer::Result

Builds a survived result.

Returns:



91
# File 'lib/mutineer/result.rb', line 91

def self.survived = new(status: :survived, details: nil, subject: nil, mutation: nil, id: nil)

.timeout ⇒ Mutineer::Result

Builds a timeout result.

Returns:



102
# File 'lib/mutineer/result.rb', line 102

def self.timeout = new(status: :timeout, details: nil, subject: nil, mutation: nil, id: nil)

.uncapturable ⇒ Mutineer::Result

Builds an uncapturable result.

Returns:



118
# File 'lib/mutineer/result.rb', line 118

def self.uncapturable = new(status: :uncapturable, details: nil, subject: nil, mutation: nil, id: nil)

.unplaceable ⇒ Mutineer::Result

Builds an unplaceable result.

Returns:



123
# File 'lib/mutineer/result.rb', line 123

def self.unplaceable = new(status: :unplaceable, details: nil, subject: nil, mutation: nil, id: nil)

Instance Method Details

#error? ⇒ Boolean

Returns true when the status is error.

Returns:

  • (Boolean) —

    true when the status is error.



140
141
# File 'lib/mutineer/result.rb', line 140

def error?        = status == :error
# @return [Boolean] true when the status is timeout.

#ignored? ⇒ Boolean

Returns true when the status is ignored.

Returns:

  • (Boolean) —

    true when the status is ignored.



154
# File 'lib/mutineer/result.rb', line 154

def ignored?      = status == :ignored

#killed? ⇒ Boolean

Returns true when the status is killed.

Returns:

  • (Boolean) —

    true when the status is killed.



136
137
# File 'lib/mutineer/result.rb', line 136

def killed?       = status == :killed
# @return [Boolean] true when the status is survived.

#no_coverage? ⇒ Boolean

Returns true when the status is no_coverage.

Returns:

  • (Boolean) —

    true when the status is no_coverage.



146
147
# File 'lib/mutineer/result.rb', line 146

def no_coverage?  = status == :no_coverage
# @return [Boolean] true when the status is uncapturable.

#ran_at_load? ⇒ Boolean

Returns true when the status is ran_at_load.

Returns:

  • (Boolean) —

    true when the status is ran_at_load.



152
153
# File 'lib/mutineer/result.rb', line 152

def ran_at_load?  = status == :ran_at_load
# @return [Boolean] true when the status is ignored.

#skipped? ⇒ Boolean

Returns true when the status is skipped.

Returns:

  • (Boolean) —

    true when the status is skipped.



144
145
# File 'lib/mutineer/result.rb', line 144

def skipped?      = status == :skipped
# @return [Boolean] true when the status is no_coverage.

#survived? ⇒ Boolean

Returns true when the status is survived.

Returns:

  • (Boolean) —

    true when the status is survived.



138
139
# File 'lib/mutineer/result.rb', line 138

def survived?     = status == :survived
# @return [Boolean] true when the status is error.

#timeout? ⇒ Boolean

Returns true when the status is timeout.

Returns:

  • (Boolean) —

    true when the status is timeout.



142
143
# File 'lib/mutineer/result.rb', line 142

def timeout?      = status == :timeout
# @return [Boolean] true when the status is skipped.

#uncapturable? ⇒ Boolean

Returns true when the status is uncapturable.

Returns:

  • (Boolean) —

    true when the status is uncapturable.



148
149
# File 'lib/mutineer/result.rb', line 148

def uncapturable? = status == :uncapturable
# @return [Boolean] true when the status is unplaceable.

#unplaceable? ⇒ Boolean

Returns true when the status is unplaceable.

Returns:

  • (Boolean) —

    true when the status is unplaceable.



150
151
# File 'lib/mutineer/result.rb', line 150

def unplaceable?  = status == :unplaceable
# @return [Boolean] true when the status is ran_at_load.