Class: Evilution::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/config.rb

Defined Under Namespace

Modules: Builders, EnvLoader, FileLoader, Sources, Validators

Constant Summary collapse

CONFIG_FILES =
%w[.evilution.yml config/evilution.yml].freeze
DEFAULTS =
{
  timeout: 30, format: :text, target: nil, min_score: 0.0, integration: :rspec,
  verbose: false, quiet: false, jobs: 1, fail_fast: nil, baseline: true,
  isolation: :auto, incremental: false, suggest_tests: false, progress: true,
  save_session: false, line_ranges: {}, spec_files: [], ignore_patterns: [],
  show_disabled: false, baseline_session: nil, skip_heredoc_literals: false,
  related_specs_heuristic: false, fallback_to_full_suite: false, preload: nil,
  spec_mappings: {}, spec_pattern: nil, example_targeting: true,
  example_targeting_fallback: :full_file,
  example_targeting_cache: { max_files: 50, max_blocks: 10_000 },
  quiet_children: false, quiet_children_dir: "tmp/evilution_children"
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Config

Returns a new instance of Config.



33
34
35
36
37
38
# File 'lib/evilution/config.rb', line 33

def initialize(**options)
  skip_file = options.delete(:skip_config_file) ? true : false
  merged = Sources.merge(explicit: options, skip_file: skip_file)
  assign_attributes(merged)
  freeze
end

Instance Attribute Details

#baselineObject (readonly)

Returns the value of attribute baseline.



23
24
25
# File 'lib/evilution/config.rb', line 23

def baseline
  @baseline
end

#baseline_sessionObject (readonly)

Returns the value of attribute baseline_session.



23
24
25
# File 'lib/evilution/config.rb', line 23

def baseline_session
  @baseline_session
end

#example_targetingObject (readonly)

Returns the value of attribute example_targeting.



23
24
25
# File 'lib/evilution/config.rb', line 23

def example_targeting
  @example_targeting
end

#example_targeting_cacheObject (readonly)

Returns the value of attribute example_targeting_cache.



23
24
25
# File 'lib/evilution/config.rb', line 23

def example_targeting_cache
  @example_targeting_cache
end

#example_targeting_fallbackObject (readonly)

Returns the value of attribute example_targeting_fallback.



23
24
25
# File 'lib/evilution/config.rb', line 23

def example_targeting_fallback
  @example_targeting_fallback
end

#fail_fastObject (readonly)

Returns the value of attribute fail_fast.



23
24
25
# File 'lib/evilution/config.rb', line 23

def fail_fast
  @fail_fast
end

#fallback_to_full_suiteObject (readonly)

Returns the value of attribute fallback_to_full_suite.



23
24
25
# File 'lib/evilution/config.rb', line 23

def fallback_to_full_suite
  @fallback_to_full_suite
end

#formatObject (readonly)

Returns the value of attribute format.



23
24
25
# File 'lib/evilution/config.rb', line 23

def format
  @format
end

#hooksObject (readonly)

Returns the value of attribute hooks.



23
24
25
# File 'lib/evilution/config.rb', line 23

def hooks
  @hooks
end

#ignore_patternsObject (readonly)

Returns the value of attribute ignore_patterns.



23
24
25
# File 'lib/evilution/config.rb', line 23

def ignore_patterns
  @ignore_patterns
end

#incrementalObject (readonly)

Returns the value of attribute incremental.



23
24
25
# File 'lib/evilution/config.rb', line 23

def incremental
  @incremental
end

#integrationObject (readonly)

Returns the value of attribute integration.



23
24
25
# File 'lib/evilution/config.rb', line 23

def integration
  @integration
end

#isolationObject (readonly)

Returns the value of attribute isolation.



23
24
25
# File 'lib/evilution/config.rb', line 23

def isolation
  @isolation
end

#jobsObject (readonly)

Returns the value of attribute jobs.



23
24
25
# File 'lib/evilution/config.rb', line 23

def jobs
  @jobs
end

#line_rangesObject (readonly)

Returns the value of attribute line_ranges.



23
24
25
# File 'lib/evilution/config.rb', line 23

def line_ranges
  @line_ranges
end

#min_scoreObject (readonly)

Returns the value of attribute min_score.



23
24
25
# File 'lib/evilution/config.rb', line 23

def min_score
  @min_score
end

#preloadObject (readonly)

Returns the value of attribute preload.



23
24
25
# File 'lib/evilution/config.rb', line 23

def preload
  @preload
end

#progressObject (readonly)

Returns the value of attribute progress.



23
24
25
# File 'lib/evilution/config.rb', line 23

def progress
  @progress
end

#quietObject (readonly)

Returns the value of attribute quiet.



23
24
25
# File 'lib/evilution/config.rb', line 23

def quiet
  @quiet
end

#quiet_childrenObject (readonly)

Returns the value of attribute quiet_children.



23
24
25
# File 'lib/evilution/config.rb', line 23

def quiet_children
  @quiet_children
end

#quiet_children_dirObject (readonly)

Returns the value of attribute quiet_children_dir.



23
24
25
# File 'lib/evilution/config.rb', line 23

def quiet_children_dir
  @quiet_children_dir
end

Returns the value of attribute related_specs_heuristic.



23
24
25
# File 'lib/evilution/config.rb', line 23

def related_specs_heuristic
  @related_specs_heuristic
end

#save_sessionObject (readonly)

Returns the value of attribute save_session.



23
24
25
# File 'lib/evilution/config.rb', line 23

def save_session
  @save_session
end

#show_disabledObject (readonly)

Returns the value of attribute show_disabled.



23
24
25
# File 'lib/evilution/config.rb', line 23

def show_disabled
  @show_disabled
end

#skip_heredoc_literalsObject (readonly)

Returns the value of attribute skip_heredoc_literals.



23
24
25
# File 'lib/evilution/config.rb', line 23

def skip_heredoc_literals
  @skip_heredoc_literals
end

#spec_filesObject (readonly)

Returns the value of attribute spec_files.



23
24
25
# File 'lib/evilution/config.rb', line 23

def spec_files
  @spec_files
end

#spec_mappingsObject (readonly)

Returns the value of attribute spec_mappings.



23
24
25
# File 'lib/evilution/config.rb', line 23

def spec_mappings
  @spec_mappings
end

#spec_patternObject (readonly)

Returns the value of attribute spec_pattern.



23
24
25
# File 'lib/evilution/config.rb', line 23

def spec_pattern
  @spec_pattern
end

#spec_selectorObject (readonly)

Returns the value of attribute spec_selector.



23
24
25
# File 'lib/evilution/config.rb', line 23

def spec_selector
  @spec_selector
end

#suggest_testsObject (readonly)

Returns the value of attribute suggest_tests.



23
24
25
# File 'lib/evilution/config.rb', line 23

def suggest_tests
  @suggest_tests
end

#targetObject (readonly)

Returns the value of attribute target.



23
24
25
# File 'lib/evilution/config.rb', line 23

def target
  @target
end

#target_filesObject (readonly)

Returns the value of attribute target_files.



23
24
25
# File 'lib/evilution/config.rb', line 23

def target_files
  @target_files
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



23
24
25
# File 'lib/evilution/config.rb', line 23

def timeout
  @timeout
end

#verboseObject (readonly)

Returns the value of attribute verbose.



23
24
25
# File 'lib/evilution/config.rb', line 23

def verbose
  @verbose
end

Class Method Details

.default_templateObject

Generates a default config file template.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/evilution/config.rb', line 109

def self.default_template
  <<~YAML
    # Evilution configuration
    # See: https://github.com/marinazzio/evilution

    # Per-mutation timeout in seconds (default: 30)
    # timeout: 30

    # Output format: text or json (default: text)
    # format: text

    # Minimum mutation score to pass (0.0 to 1.0, default: 0.0)
    # min_score: 0.0

    # Test integration: rspec, minitest (default: rspec)
    # integration: rspec

    # Number of parallel workers (default: 1)
    # jobs: 1

    # Stop after N surviving mutants (default: disabled)
    # fail_fast: 1

    # Generate concrete test code in suggestions, matching integration (default: false)
    # suggest_tests: false

    # Skip all string literal mutations inside heredocs (default: false).
    # Useful for Rails apps where heredoc content (SQL, templates, fixtures)
    # rarely has meaningful test coverage and produces noisy survivors.
    # skip_heredoc_literals: true

    # Opt into the RelatedSpecHeuristic, which appends request/integration/
    # feature/system specs for mutations that touch `.includes(...)` calls
    # (default: false). Off by default because the fan-out can be heavy and
    # push runs over the per-mutation timeout. Enable if you need coverage
    # of N+1 regressions that only surface in higher-level specs.
    # related_specs_heuristic: true

    # When no matching spec resolves for a mutation's source file, the
    # default is to skip that mutation and mark it :unresolved in the
    # report (a coverage gap signal). Set to true to fall back to running
    # the entire test suite for such mutations instead (slow, high memory).
    # fallback_to_full_suite: false

    # Preload file required in the parent process before forking workers.
    # For Rails projects, the autodetect chain tries (in order):
    # spec/rails_helper.rb -> spec/spec_helper.rb -> test/test_helper.rb
    # when isolation resolves to :fork. Set to false to disable.
    # preload: spec/rails_helper.rb # or spec/spec_helper.rb, test/test_helper.rb

    # Hooks: Ruby files returning a Proc, keyed by lifecycle event
    # hooks:
    #   worker_process_start: config/evilution_hooks/worker_start.rb
    #   mutation_insert_pre: config/evilution_hooks/mutation_pre.rb

    # Per-mutation example targeting (default: true). When enabled, Evilution
    # parses resolved spec files and restricts each mutation run to examples
    # whose bodies reference the mutated method/class token. Set to false
    # to run every example in the resolved spec files. You can also disable
    # without editing the file by exporting EV_DISABLE_EXAMPLE_TARGETING=1.
    # example_targeting: true

    # Behavior when targeting finds no matching example (default: full_file).
    # full_file  - run every example in the resolved spec files
    # unresolved - mark the mutation :unresolved and skip
    # example_targeting_fallback: full_file

    # LRU cache bounds for the spec AST parser that powers example targeting.
    # example_targeting_cache:
    #   max_files: 50
    #   max_blocks: 10000

    # AST patterns to skip during mutation generation (default: [])
    # See docs/ast_pattern_syntax.md for pattern syntax
    # ignore_patterns:
    #   - "call{name=info, receiver=call{name=logger}}"
    #   - "call{name=debug|warn}"
  YAML
end

.file_optionsObject



104
105
106
# File 'lib/evilution/config.rb', line 104

def self.file_options
  FileLoader.load
end

Instance Method Details

#baseline?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/evilution/config.rb', line 64

def baseline?
  baseline
end

#example_targeting?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/evilution/config.rb', line 96

def example_targeting?
  example_targeting
end

#fail_fast?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/evilution/config.rb', line 60

def fail_fast?
  !fail_fast.nil?
end

#fallback_to_full_suite?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/evilution/config.rb', line 100

def fallback_to_full_suite?
  fallback_to_full_suite
end

#html?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/evilution/config.rb', line 48

def html?
  format == :html
end

#incremental?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/evilution/config.rb', line 68

def incremental?
  incremental
end

#json?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/evilution/config.rb', line 40

def json?
  format == :json
end

#line_ranges?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/evilution/config.rb', line 52

def line_ranges?
  !line_ranges.empty?
end

#progress?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/evilution/config.rb', line 76

def progress?
  progress
end

Returns:

  • (Boolean)


92
93
94
# File 'lib/evilution/config.rb', line 92

def related_specs_heuristic?
  related_specs_heuristic
end

#save_session?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/evilution/config.rb', line 80

def save_session?
  save_session
end

#show_disabled?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/evilution/config.rb', line 84

def show_disabled?
  show_disabled
end

#skip_heredoc_literals?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/evilution/config.rb', line 88

def skip_heredoc_literals?
  skip_heredoc_literals
end

#suggest_tests?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/evilution/config.rb', line 72

def suggest_tests?
  suggest_tests
end

#target?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/evilution/config.rb', line 56

def target?
  !target.nil?
end

#text?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/evilution/config.rb', line 44

def text?
  format == :text
end