Class: Mutant::Env Private
- Inherits:
-
Object
- Object
- Mutant::Env
- Includes:
- Unparser::Adamantium
- Defined in:
- lib/mutant/env.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Mutation testing execution environment
Constant Summary collapse
- SEMANTICS_MESSAGE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"Fix your lib to follow normal ruby semantics!\n" \ '{Module,Class}#name should return resolvable constant name as String or nil'
Class Method Summary collapse
-
.empty(world, config) ⇒ Env
private
Construct minimal empty env.
Instance Method Summary collapse
-
#amount_all_tests ⇒ Integer
private
Amount of all tests the integration provides.
-
#amount_available_tests ⇒ Integer
private
Amount of tests available for mutation testing.
-
#amount_mutations ⇒ Integer
private
Amount of mutations.
-
#amount_selected_tests ⇒ Integer
private
Amount of selected tests.
-
#amount_subjects ⇒ Integer
private
Amount of selected subjects.
-
#cover_index(mutation_index) ⇒ Result::MutationIndex
private
Cover mutation with specific index.
- #emit_mutation_worker_process_start(index:) ⇒ Object private
- #emit_test_worker_process_start(index:) ⇒ Object private
-
#record(name) ⇒ self
private
Record segment.
- #run_test_index(test_index) ⇒ Object private
-
#selected_tests ⇒ Set<Test>
private
Selected tests.
-
#selections ⇒ Object
private
The test selections.
-
#test_subject_ratio ⇒ Rational
private
Ratio between selected tests and subjects.
-
#warn(message) ⇒ self
private
Emit warning.
Class Method Details
.empty(world, config) ⇒ Env
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Construct minimal empty env
rubocop:disable Metrics/MethodLength
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mutant/env.rb', line 30 def self.empty(world, config) new( config:, hooks: Hooks.empty, integration: Integration::Null.new( arguments: EMPTY_ARRAY, expression_parser: config.expression_parser, world: ), matchable_scopes: EMPTY_ARRAY, mutations: EMPTY_ARRAY, parser: Parser.new, selector: Selector::Null.new, subjects: EMPTY_ARRAY, world: ) end |
Instance Method Details
#amount_all_tests ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Amount of all tests the integration provides
112 |
# File 'lib/mutant/env.rb', line 112 def amount_all_tests = integration.all_tests.length |
#amount_available_tests ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Amount of tests available for mutation testing
118 |
# File 'lib/mutant/env.rb', line 118 def amount_available_tests = integration.available_tests.length |
#amount_mutations ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Amount of mutations
106 |
# File 'lib/mutant/env.rb', line 106 def amount_mutations = mutations.length |
#amount_selected_tests ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Amount of selected tests
130 |
# File 'lib/mutant/env.rb', line 130 def amount_selected_tests = selected_tests.length |
#amount_subjects ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Amount of selected subjects
124 |
# File 'lib/mutant/env.rb', line 124 def amount_subjects = subjects.length |
#cover_index(mutation_index) ⇒ Result::MutationIndex
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Cover mutation with specific index
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mutant/env.rb', line 54 def cover_index(mutation_index) mutation = mutations.fetch(mutation_index) start = timer.now tests = selections.fetch(mutation.subject) Result::MutationIndex.new( isolation_result: run_mutation_tests(mutation, tests), mutation_index:, runtime: timer.now - start ) end |
#emit_mutation_worker_process_start(index:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 |
# File 'lib/mutant/env.rb', line 72 def emit_mutation_worker_process_start(index:) hooks.run(:mutation_worker_process_start, index:) end |
#emit_test_worker_process_start(index:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 |
# File 'lib/mutant/env.rb', line 76 def emit_test_worker_process_start(index:) hooks.run(:test_worker_process_start, index:) end |
#record(name) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Record segment
148 149 150 |
# File 'lib/mutant/env.rb', line 148 def record(name, &) world.record(name, &) end |
#run_test_index(test_index) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/mutant/env.rb', line 68 def run_test_index(test_index) integration.call([integration.all_tests.fetch(test_index)]) end |
#selected_tests ⇒ Set<Test>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Selected tests
100 |
# File 'lib/mutant/env.rb', line 100 def selected_tests = selections.values.flatten.to_set |
#selections ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The test selections
83 84 85 86 87 |
# File 'lib/mutant/env.rb', line 83 def selections subjects.to_h do |subject| [subject, selector.call(subject)] end end |
#test_subject_ratio ⇒ Rational
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ratio between selected tests and subjects
136 137 138 139 140 |
# File 'lib/mutant/env.rb', line 136 def test_subject_ratio return Rational(0) if amount_subjects.zero? Rational(amount_selected_tests, amount_subjects) end |
#warn(message) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Emit warning
95 |
# File 'lib/mutant/env.rb', line 95 def warn() = tap { config.reporter.warn() } |