Class: MutationTester::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/mutation_tester/configuration.rb

Constant Summary collapse

RUNNER_MODES =
%i[auto fork spawn in_memory].freeze
AUTO_PARALLEL_CAP =
8

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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
59
60
# File 'lib/mutation_tester/configuration.rb', line 32

def initialize
  self.parallel_processes = ENV['MUTATION_TESTER_PARALLEL_PROCESSES'] || self.class.auto_parallel_processes
  self.runner = ENV['MUTATION_TESTER_RUNNER'] || :auto
  self.worker_env_var = ENV['MUTATION_TESTER_WORKER_ENV']
  @timeout = 30
  @baseline_timeout = 300
  @mutation_types = {
    arithmetic: true,
    comparison: true,
    logical: true,
    boolean: true,
    number: true,
    string: true,
    conditional: true,
    call_removal: true,
    nil_injection: true,
    argument: true,
    strict_equality: false
  }
  @reporters = %i[console html json]
  @output_dir = 'tmp/mutation_reports'
  @minimum_score = 80.0
  @fail_on_threshold = true
  @verbose = false
  @show_file_path = true
  @show_progress = true
  @test_selection = true
  @fail_fast = false
end

Instance Attribute Details

#baseline_timeoutObject

Returns the value of attribute baseline_timeout.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def baseline_timeout
  @baseline_timeout
end

#fail_fastObject

Returns the value of attribute fail_fast.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def fail_fast
  @fail_fast
end

#fail_on_thresholdObject

Returns the value of attribute fail_on_threshold.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def fail_on_threshold
  @fail_on_threshold
end

#minimum_scoreObject

Returns the value of attribute minimum_score.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def minimum_score
  @minimum_score
end

#mutation_typesObject

Returns the value of attribute mutation_types.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def mutation_types
  @mutation_types
end

#output_dirObject

Returns the value of attribute output_dir.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def output_dir
  @output_dir
end

#parallel_processesObject

Returns the value of attribute parallel_processes.



17
18
19
# File 'lib/mutation_tester/configuration.rb', line 17

def parallel_processes
  @parallel_processes
end

#reportersObject

Returns the value of attribute reporters.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def reporters
  @reporters
end

#runnerObject

Returns the value of attribute runner.



17
18
19
# File 'lib/mutation_tester/configuration.rb', line 17

def runner
  @runner
end

#show_file_pathObject

Returns the value of attribute show_file_path.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def show_file_path
  @show_file_path
end

#show_progressObject

Returns the value of attribute show_progress.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def show_progress
  @show_progress
end

#test_selectionObject

Returns the value of attribute test_selection.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def test_selection
  @test_selection
end

#timeoutObject

Returns the value of attribute timeout.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def timeout
  @timeout
end

#verboseObject

Returns the value of attribute verbose.



19
20
21
# File 'lib/mutation_tester/configuration.rb', line 19

def verbose
  @verbose
end

#worker_env_varObject

Returns the value of attribute worker_env_var.



17
18
19
# File 'lib/mutation_tester/configuration.rb', line 17

def worker_env_var
  @worker_env_var
end

Class Method Details

.auto_parallel_processesObject



8
9
10
# File 'lib/mutation_tester/configuration.rb', line 8

def self.auto_parallel_processes
  [[Etc.nprocessors, AUTO_PARALLEL_CAP].min, 1].max
end

.worker_env_value(index) ⇒ Object



12
13
14
15
# File 'lib/mutation_tester/configuration.rb', line 12

def self.worker_env_value(index)
  number = index.to_i
  number <= 0 ? '' : (number + 1).to_s
end

Instance Method Details

#initialize_copy(source) ⇒ Object



70
71
72
73
74
# File 'lib/mutation_tester/configuration.rb', line 70

def initialize_copy(source)
  super
  @mutation_types = source.mutation_types.dup
  @reporters = source.reporters.dup
end

#merge(options) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/mutation_tester/configuration.rb', line 62

def merge(options)
  config = dup
  options.each do |key, value|
    config.public_send("#{key}=", value) if config.respond_to?("#{key}=")
  end
  config
end

#worker_env_assignment(index) ⇒ Object



99
100
101
102
103
# File 'lib/mutation_tester/configuration.rb', line 99

def worker_env_assignment(index)
  return nil unless @worker_env_var

  { @worker_env_var => self.class.worker_env_value(index) }
end