Class: MutationTester::Configuration
- Inherits:
-
Object
- Object
- MutationTester::Configuration
- Defined in:
- lib/mutation_tester/configuration.rb
Constant Summary collapse
- RUNNER_MODES =
%i[auto fork spawn in_memory].freeze
- TIMEOUT_POLICIES =
%i[killed separate].freeze
- AUTO_PARALLEL_CAP =
8- DEFAULT_TIMEOUT =
30- DEFAULT_TIMEOUT_FACTOR =
5- CALIBRATED_TIMEOUT_FLOOR =
5
Instance Attribute Summary collapse
-
#baseline_duration ⇒ Object
Returns the value of attribute baseline_duration.
-
#baseline_timeout ⇒ Object
Returns the value of attribute baseline_timeout.
-
#fail_fast ⇒ Object
Returns the value of attribute fail_fast.
-
#fail_on_threshold ⇒ Object
Returns the value of attribute fail_on_threshold.
-
#minimum_score ⇒ Object
Returns the value of attribute minimum_score.
-
#mutation_types ⇒ Object
Returns the value of attribute mutation_types.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#parallel_processes ⇒ Object
Returns the value of attribute parallel_processes.
-
#reporters ⇒ Object
Returns the value of attribute reporters.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#show_file_path ⇒ Object
Returns the value of attribute show_file_path.
-
#show_progress ⇒ Object
Returns the value of attribute show_progress.
-
#test_selection ⇒ Object
Returns the value of attribute test_selection.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#timeout_factor ⇒ Object
Returns the value of attribute timeout_factor.
-
#timeout_policy ⇒ Object
Returns the value of attribute timeout_policy.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#worker_env_var ⇒ Object
Returns the value of attribute worker_env_var.
Class Method Summary collapse
Instance Method Summary collapse
- #effective_timeout ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #initialize_copy(source) ⇒ Object
- #merge(options) ⇒ Object
- #timeout_explicitly_set? ⇒ Boolean
- #worker_env_assignment(index) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
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 61 62 63 64 65 66 |
# File 'lib/mutation_tester/configuration.rb', line 36 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 = DEFAULT_TIMEOUT @timeout_factor = DEFAULT_TIMEOUT_FACTOR @timeout_policy = :killed @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_duration ⇒ Object
Returns the value of attribute baseline_duration.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def baseline_duration @baseline_duration end |
#baseline_timeout ⇒ Object
Returns the value of attribute baseline_timeout.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def baseline_timeout @baseline_timeout end |
#fail_fast ⇒ Object
Returns the value of attribute fail_fast.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def fail_fast @fail_fast end |
#fail_on_threshold ⇒ Object
Returns the value of attribute fail_on_threshold.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def fail_on_threshold @fail_on_threshold end |
#minimum_score ⇒ Object
Returns the value of attribute minimum_score.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def minimum_score @minimum_score end |
#mutation_types ⇒ Object
Returns the value of attribute mutation_types.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def mutation_types @mutation_types end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def output_dir @output_dir end |
#parallel_processes ⇒ Object
Returns the value of attribute parallel_processes.
21 22 23 |
# File 'lib/mutation_tester/configuration.rb', line 21 def parallel_processes @parallel_processes end |
#reporters ⇒ Object
Returns the value of attribute reporters.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def reporters @reporters end |
#runner ⇒ Object
Returns the value of attribute runner.
21 22 23 |
# File 'lib/mutation_tester/configuration.rb', line 21 def runner @runner end |
#show_file_path ⇒ Object
Returns the value of attribute show_file_path.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def show_file_path @show_file_path end |
#show_progress ⇒ Object
Returns the value of attribute show_progress.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def show_progress @show_progress end |
#test_selection ⇒ Object
Returns the value of attribute test_selection.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def test_selection @test_selection end |
#timeout ⇒ Object
Returns the value of attribute timeout.
21 22 23 |
# File 'lib/mutation_tester/configuration.rb', line 21 def timeout @timeout end |
#timeout_factor ⇒ Object
Returns the value of attribute timeout_factor.
21 22 23 |
# File 'lib/mutation_tester/configuration.rb', line 21 def timeout_factor @timeout_factor end |
#timeout_policy ⇒ Object
Returns the value of attribute timeout_policy.
21 22 23 |
# File 'lib/mutation_tester/configuration.rb', line 21 def timeout_policy @timeout_policy end |
#verbose ⇒ Object
Returns the value of attribute verbose.
23 24 25 |
# File 'lib/mutation_tester/configuration.rb', line 23 def verbose @verbose end |
#worker_env_var ⇒ Object
Returns the value of attribute worker_env_var.
21 22 23 |
# File 'lib/mutation_tester/configuration.rb', line 21 def worker_env_var @worker_env_var end |
Class Method Details
.auto_parallel_processes ⇒ Object
12 13 14 |
# File 'lib/mutation_tester/configuration.rb', line 12 def self.auto_parallel_processes [[Etc.nprocessors, AUTO_PARALLEL_CAP].min, 1].max end |
.worker_env_value(index) ⇒ Object
16 17 18 19 |
# File 'lib/mutation_tester/configuration.rb', line 16 def self.worker_env_value(index) number = index.to_i number <= 0 ? '' : (number + 1).to_s end |
Instance Method Details
#effective_timeout ⇒ Object
109 110 111 112 113 |
# File 'lib/mutation_tester/configuration.rb', line 109 def effective_timeout return @timeout if timeout_explicitly_set? || @baseline_duration.nil? [CALIBRATED_TIMEOUT_FLOOR, @timeout_factor * @baseline_duration].max end |
#initialize_copy(source) ⇒ Object
76 77 78 79 80 |
# File 'lib/mutation_tester/configuration.rb', line 76 def initialize_copy(source) super @mutation_types = source.mutation_types.dup @reporters = source.reporters.dup end |
#merge(options) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/mutation_tester/configuration.rb', line 68 def merge() config = dup .each do |key, value| config.public_send("#{key}=", value) if config.respond_to?("#{key}=") end config end |
#timeout_explicitly_set? ⇒ Boolean
87 88 89 |
# File 'lib/mutation_tester/configuration.rb', line 87 def timeout_explicitly_set? !!@timeout_explicit end |
#worker_env_assignment(index) ⇒ Object
138 139 140 141 142 |
# File 'lib/mutation_tester/configuration.rb', line 138 def worker_env_assignment(index) return nil unless @worker_env_var { @worker_env_var => self.class.worker_env_value(index) } end |