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_MINIMUM_SCORE =
80.0- DEFAULT_TIMEOUT =
30- DEFAULT_TIMEOUT_FACTOR =
5- CALIBRATED_TIMEOUT_FLOOR =
5
Instance Attribute Summary collapse
-
#after_fork_file ⇒ Object
Returns the value of attribute after_fork_file.
-
#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.
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 67 68 69 |
# File 'lib/mutation_tester/configuration.rb', line 38 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'] self.after_fork_file = ENV['MUTATION_TESTER_AFTER_FORK'] @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 = DEFAULT_MINIMUM_SCORE @fail_on_threshold = true @verbose = false @show_file_path = true @show_progress = true @test_selection = true @fail_fast = false end |
Instance Attribute Details
#after_fork_file ⇒ Object
Returns the value of attribute after_fork_file.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def after_fork_file @after_fork_file end |
#baseline_duration ⇒ Object
Returns the value of attribute baseline_duration.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def baseline_duration @baseline_duration end |
#baseline_timeout ⇒ Object
Returns the value of attribute baseline_timeout.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def baseline_timeout @baseline_timeout end |
#fail_fast ⇒ Object
Returns the value of attribute fail_fast.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def fail_fast @fail_fast end |
#fail_on_threshold ⇒ Object
Returns the value of attribute fail_on_threshold.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def fail_on_threshold @fail_on_threshold end |
#minimum_score ⇒ Object
Returns the value of attribute minimum_score.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def minimum_score @minimum_score end |
#mutation_types ⇒ Object
Returns the value of attribute mutation_types.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def mutation_types @mutation_types end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def output_dir @output_dir end |
#parallel_processes ⇒ Object
Returns the value of attribute parallel_processes.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def parallel_processes @parallel_processes end |
#reporters ⇒ Object
Returns the value of attribute reporters.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def reporters @reporters end |
#runner ⇒ Object
Returns the value of attribute runner.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def runner @runner end |
#show_file_path ⇒ Object
Returns the value of attribute show_file_path.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def show_file_path @show_file_path end |
#show_progress ⇒ Object
Returns the value of attribute show_progress.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def show_progress @show_progress end |
#test_selection ⇒ Object
Returns the value of attribute test_selection.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def test_selection @test_selection end |
#timeout ⇒ Object
Returns the value of attribute timeout.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def timeout @timeout end |
#timeout_factor ⇒ Object
Returns the value of attribute timeout_factor.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def timeout_factor @timeout_factor end |
#timeout_policy ⇒ Object
Returns the value of attribute timeout_policy.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def timeout_policy @timeout_policy end |
#verbose ⇒ Object
Returns the value of attribute verbose.
25 26 27 |
# File 'lib/mutation_tester/configuration.rb', line 25 def verbose @verbose end |
#worker_env_var ⇒ Object
Returns the value of attribute worker_env_var.
22 23 24 |
# File 'lib/mutation_tester/configuration.rb', line 22 def worker_env_var @worker_env_var end |
Class Method Details
.auto_parallel_processes ⇒ Object
13 14 15 |
# File 'lib/mutation_tester/configuration.rb', line 13 def self.auto_parallel_processes [[Etc.nprocessors, AUTO_PARALLEL_CAP].min, 1].max end |
.worker_env_value(index) ⇒ Object
17 18 19 20 |
# File 'lib/mutation_tester/configuration.rb', line 17 def self.worker_env_value(index) number = index.to_i number <= 0 ? '' : (number + 1).to_s end |
Instance Method Details
#effective_timeout ⇒ Object
112 113 114 115 116 |
# File 'lib/mutation_tester/configuration.rb', line 112 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
79 80 81 82 83 |
# File 'lib/mutation_tester/configuration.rb', line 79 def initialize_copy(source) super @mutation_types = source.mutation_types.dup @reporters = source.reporters.dup end |
#merge(options) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/mutation_tester/configuration.rb', line 71 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
90 91 92 |
# File 'lib/mutation_tester/configuration.rb', line 90 def timeout_explicitly_set? !!@timeout_explicit end |
#worker_env_assignment(index) ⇒ Object
146 147 148 149 150 |
# File 'lib/mutation_tester/configuration.rb', line 146 def worker_env_assignment(index) return nil unless @worker_env_var { @worker_env_var => self.class.worker_env_value(index) } end |