diff --git a/lib/mutant.rb b/lib/mutant.rb index 6ee095c9..e331a4d2 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -192,22 +192,22 @@ module Mutant DEFAULT = new( debug: false, - fail_fast: false, - integration: Integration::Null, - matcher: Matcher::Config::DEFAULT, - includes: EMPTY_ARRAY, - requires: EMPTY_ARRAY, - isolation: Mutant::Isolation::Fork, - reporter: Reporter::CLI.build($stdout), - zombie: false, - jobs: Mutant.ci? ? CI_DEFAULT_PROCESSOR_COUNT : ::Parallel.processor_count, expected_coverage: Rational(1), expression_parser: Expression::Parser.new([ Expression::Method, Expression::Methods, Expression::Namespace::Exact, Expression::Namespace::Recursive - ]) + ]), + fail_fast: false, + includes: EMPTY_ARRAY, + integration: Integration::Null, + isolation: Mutant::Isolation::Fork, + jobs: Mutant.ci? ? CI_DEFAULT_PROCESSOR_COUNT : ::Parallel.processor_count, + matcher: Matcher::Config::DEFAULT, + requires: EMPTY_ARRAY, + reporter: Reporter::CLI.build($stdout), + zombie: false ) end # Config end # Mutant diff --git a/lib/mutant/config.rb b/lib/mutant/config.rb index 9d0e4460..9aec35fe 100644 --- a/lib/mutant/config.rb +++ b/lib/mutant/config.rb @@ -6,17 +6,17 @@ module Mutant class Config include Adamantium::Flat, Anima.new( :debug, + :expected_coverage, + :expression_parser, + :fail_fast, :integration, - :matcher, :includes, + :isolation, + :jobs, + :matcher, :requires, :reporter, - :isolation, - :fail_fast, - :jobs, - :zombie, - :expected_coverage, - :expression_parser + :zombie ) %i[fail_fast zombie debug].each do |name| diff --git a/lib/mutant/env.rb b/lib/mutant/env.rb index 022828a8..e77f0b94 100644 --- a/lib/mutant/env.rb +++ b/lib/mutant/env.rb @@ -2,14 +2,14 @@ module Mutant # Abstract base class for mutant environments class Env include Adamantium::Flat, Anima.new( - :config, :actor_env, - :parser, - :subjects, - :matchable_scopes, + :config, :integration, + :matchable_scopes, + :mutations, + :parser, :selector, - :mutations + :subjects ) SEMANTICS_MESSAGE = @@ -53,10 +53,10 @@ module Mutant end rescue Isolation::Error => error Result::Test.new( - tests: tests, output: error.message, + passed: false, runtime: Time.now - start, - passed: false + tests: tests ) end diff --git a/lib/mutant/env/bootstrap.rb b/lib/mutant/env/bootstrap.rb index 6f99322b..2c0095e5 100644 --- a/lib/mutant/env/bootstrap.rb +++ b/lib/mutant/env/bootstrap.rb @@ -64,12 +64,12 @@ module Mutant Env.new( actor_env: Actor::Env.new(Thread), config: config, - parser: parser, - subjects: subjects, - matchable_scopes: matchable_scopes, integration: @integration, + matchable_scopes: matchable_scopes, + mutations: subjects.flat_map(&:mutations), + parser: parser, selector: Selector::Expression.new(@integration), - mutations: subjects.flat_map(&:mutations) + subjects: subjects ) end @@ -91,9 +91,9 @@ module Mutant rescue => exception semantics_warning( CLASS_NAME_RAISED_EXCEPTION, - scope_class: scope.class, + exception: exception.inspect, scope: scope, - exception: exception.inspect + scope_class: scope.class ) nil end @@ -149,9 +149,9 @@ module Mutant unless name.instance_of?(String) semantics_warning( CLASS_NAME_TYPE_MISMATCH_FORMAT, + name: name, scope_class: scope.class, - scope: scope, - name: name + scope: scope ) return end diff --git a/lib/mutant/expression/method.rb b/lib/mutant/expression/method.rb index 67b736e0..15f954f5 100644 --- a/lib/mutant/expression/method.rb +++ b/lib/mutant/expression/method.rb @@ -3,7 +3,12 @@ module Mutant # Explicit method expression class Method < self - include Anima.new(:scope_name, :scope_symbol, :method_name) + include Anima.new( + :method_name, + :scope_name, + :scope_symbol + ) + private(*anima.attribute_names) MATCHERS = IceNine.deep_freeze( diff --git a/lib/mutant/expression/methods.rb b/lib/mutant/expression/methods.rb index 1549c8aa..ce3d18af 100644 --- a/lib/mutant/expression/methods.rb +++ b/lib/mutant/expression/methods.rb @@ -3,7 +3,11 @@ module Mutant # Abstract base class for methods expression class Methods < self - include Anima.new(:scope_name, :scope_symbol) + include Anima.new( + :scope_name, + :scope_symbol + ) + private(*anima.attribute_names) MATCHERS = IceNine.deep_freeze( diff --git a/lib/mutant/integration.rb b/lib/mutant/integration.rb index c4e11759..551b98a7 100644 --- a/lib/mutant/integration.rb +++ b/lib/mutant/integration.rb @@ -101,10 +101,10 @@ module Mutant # @api private def call(tests) Result::Test.new( - tests: tests, output: '', + passed: true, runtime: 0.0, - passed: true + tests: tests ) end diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index 5257e36a..30bc598c 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -68,10 +68,10 @@ module Mutant passed = @runner.run_specs(@world.ordered_example_groups).equal?(EXIT_SUCCESS) @output.rewind Result::Test.new( - tests: tests, output: @output.read, + passed: passed, runtime: Time.now - start, - passed: passed + tests: tests ) end @@ -113,8 +113,8 @@ module Mutant full_description = metadata.fetch(:full_description) Test.new( - id: "rspec:#{index}:#{location}/#{full_description}", - expression: parse_expression(metadata) + expression: parse_expression(metadata), + id: "rspec:#{index}:#{location}/#{full_description}" ) end diff --git a/lib/mutant/matcher/config.rb b/lib/mutant/matcher/config.rb index 082b63c1..3fbe009f 100644 --- a/lib/mutant/matcher/config.rb +++ b/lib/mutant/matcher/config.rb @@ -3,8 +3,8 @@ module Mutant # Subject matcher configuration class Config include Adamantium, Anima.new( - :match_expressions, :ignore_expressions, + :match_expressions, :subject_filters ) @@ -14,8 +14,8 @@ module Mutant ENUM_DELIMITER = ','.freeze EMPTY_ATTRIBUTES = 'empty'.freeze PRESENTATIONS = IceNine.deep_freeze( - match_expressions: :syntax, ignore_expressions: :syntax, + match_expressions: :syntax, subject_filters: :inspect ) private_constant(*constants(false)) diff --git a/lib/mutant/parallel.rb b/lib/mutant/parallel.rb index c4af8af4..054d7cde 100644 --- a/lib/mutant/parallel.rb +++ b/lib/mutant/parallel.rb @@ -65,22 +65,38 @@ module Mutant # Job to push to workers class Job - include Adamantium::Flat, Anima.new(:index, :payload) + include Adamantium::Flat, Anima.new( + :index, + :payload + ) end # Job # Job result object received from workers class JobResult - include Adamantium::Flat, Anima.new(:job, :payload) + include Adamantium::Flat, Anima.new( + :job, + :payload + ) end # JobResult # Parallel run configuration class Config - include Adamantium::Flat, Anima.new(:env, :processor, :source, :sink, :jobs) + include Adamantium::Flat, Anima.new( + :env, + :jobs, + :processor, + :sink, + :source + ) end # Config # Parallel execution status class Status - include Adamantium::Flat, Anima.new(:payload, :done, :active_jobs) + include Adamantium::Flat, Anima.new( + :active_jobs, + :done, + :payload + ) end end # Parallel diff --git a/lib/mutant/parallel/worker.rb b/lib/mutant/parallel/worker.rb index 82697599..7c38aeff 100644 --- a/lib/mutant/parallel/worker.rb +++ b/lib/mutant/parallel/worker.rb @@ -2,7 +2,11 @@ module Mutant module Parallel # Parallel execution worker class Worker - include Adamantium::Flat, Anima.new(:mailbox, :processor, :parent) + include Adamantium::Flat, Anima.new( + :mailbox, + :parent, + :processor + ) # Run worker # @@ -62,7 +66,16 @@ module Mutant # @api private def handle_job(job) result = processor.call(job.payload) - parent.call(Actor::Message.new(:result, JobResult.new(job: job, payload: result))) + + parent.call( + Actor::Message.new( + :result, + JobResult.new( + job: job, + payload: result + ) + ) + ) end end # Worker diff --git a/lib/mutant/result.rb b/lib/mutant/result.rb index 6b6b8094..aad1471c 100644 --- a/lib/mutant/result.rb +++ b/lib/mutant/result.rb @@ -74,7 +74,11 @@ module Mutant # Env result object class Env - include Coverage, Result, Anima.new(:runtime, :env, :subject_results) + include Coverage, Result, Anima.new( + :env, + :runtime, + :subject_results + ) # Test if run is successful # @@ -123,16 +127,20 @@ module Mutant # Test result class Test include Result, Anima.new( - :tests, :output, :passed, - :runtime + :runtime, + :tests ) end # Test # Subject result class Subject - include Coverage, Result, Anima.new(:subject, :tests, :mutation_results) + include Coverage, Result, Anima.new( + :mutation_results, + :subject, + :tests + ) sum :killtime, :mutation_results sum :runtime, :mutation_results @@ -215,7 +223,10 @@ module Mutant # Mutation result class Mutation - include Result, Anima.new(:mutation, :test_result) + include Result, Anima.new( + :mutation, + :test_result + ) # The runtime # diff --git a/lib/mutant/runner.rb b/lib/mutant/runner.rb index 25ea7eb1..ca26d0a9 100644 --- a/lib/mutant/runner.rb +++ b/lib/mutant/runner.rb @@ -67,9 +67,9 @@ module Mutant Parallel::Config.new( env: env.actor_env, jobs: config.jobs, - source: Parallel::Source::Array.new(env.mutations), + processor: env.method(:kill), sink: Sink.new(env), - processor: env.method(:kill) + source: Parallel::Source::Array.new(env.mutations) ) end diff --git a/lib/mutant/subject/method.rb b/lib/mutant/subject/method.rb index 5ef5433e..858bab7f 100644 --- a/lib/mutant/subject/method.rb +++ b/lib/mutant/subject/method.rb @@ -19,9 +19,9 @@ module Mutant # @api private def expression Expression::Method.new( + method_name: name.to_s, scope_symbol: self.class::SYMBOL, - scope_name: scope.name, - method_name: name.to_s + scope_name: scope.name ) end memoize :expression diff --git a/lib/mutant/test.rb b/lib/mutant/test.rb index 7f32271b..aeca1bba 100644 --- a/lib/mutant/test.rb +++ b/lib/mutant/test.rb @@ -1,7 +1,10 @@ module Mutant # Abstract base class for test that might kill a mutation class Test - include Adamantium::Flat, Anima.new(:id, :expression) + include Adamantium::Flat, Anima.new( + :expression, + :id + ) # Identification string # diff --git a/lib/mutant/zombifier.rb b/lib/mutant/zombifier.rb index 885cc957..c30f32f6 100644 --- a/lib/mutant/zombifier.rb +++ b/lib/mutant/zombifier.rb @@ -3,13 +3,14 @@ module Mutant class Zombifier include Anima.new( :includes, - :namespace, :load_path, :kernel, + :namespace, + :pathname, :require_highjack, - :root_require, - :pathname + :root_require ) + private(*anima.attribute_names) include AST::Sexp diff --git a/spec/support/corpus.rb b/spec/support/corpus.rb index 6601f1a5..27b5b1eb 100644 --- a/spec/support/corpus.rb +++ b/spec/support/corpus.rb @@ -16,13 +16,13 @@ module MutantSpec class Project MUTEX = Mutex.new include Adamantium, Anima.new( - :name, - :repo_uri, :exclude, + :expect_coverage, :mutation_coverage, :mutation_generation, + :name, :namespace, - :expect_coverage + :repo_uri ) # Verify mutation coverage diff --git a/spec/support/ruby_vm.rb b/spec/support/ruby_vm.rb index a232a553..03751072 100644 --- a/spec/support/ruby_vm.rb +++ b/spec/support/ruby_vm.rb @@ -12,7 +12,10 @@ module MutantSpec # An event being expected, can advance the VM class EventExpectation - include AbstractType, Anima.new(:expected_payload, :trigger_requires) + include AbstractType, Anima.new( + :expected_payload, + :trigger_requires + ) DEFAULTS = IceNine.deep_freeze(trigger_requires: []) @@ -56,8 +59,8 @@ module MutantSpec handle_event( EventObservation.new( EventExpectation::Eval, - binding: binding, - source: source, + binding: binding, + source: source, source_location: location ) ) diff --git a/spec/unit/mutant/env/boostrap_spec.rb b/spec/unit/mutant/env/boostrap_spec.rb index 84f7ee9d..6eae834b 100644 --- a/spec/unit/mutant/env/boostrap_spec.rb +++ b/spec/unit/mutant/env/boostrap_spec.rb @@ -15,25 +15,25 @@ RSpec.describe Mutant::Env::Bootstrap do let(:config) do Mutant::Config::DEFAULT.with( - jobs: 1, - reporter: instance_double(Mutant::Reporter), includes: [], - requires: [], integration: integration_class, - matcher: matcher_config + jobs: 1, + matcher: matcher_config, + reporter: instance_double(Mutant::Reporter), + requires: [] ) end let(:expected_env) do Mutant::Env.new( - parser: Mutant::Parser.new, - subjects: [], + actor_env: Mutant::Actor::Env.new(Thread), + config: config, + integration: integration, matchable_scopes: [], mutations: [], - config: config, + parser: Mutant::Parser.new, selector: Mutant::Selector::Expression.new(integration), - actor_env: Mutant::Actor::Env.new(Thread), - integration: integration + subjects: [] ) end @@ -177,8 +177,8 @@ RSpec.describe Mutant::Env::Bootstrap do Mutant::Scope.new(TestApp::Empty, match_expressions.last), Mutant::Scope.new(TestApp::Literal, match_expressions.first) ], - subjects: subjects, - mutations: subjects.flat_map(&:mutations) + mutations: subjects.flat_map(&:mutations), + subjects: subjects ) end diff --git a/spec/unit/mutant/env_spec.rb b/spec/unit/mutant/env_spec.rb index 29b376f1e..1faf971e 100644 --- a/spec/unit/mutant/env_spec.rb +++ b/spec/unit/mutant/env_spec.rb @@ -2,14 +2,14 @@ RSpec.describe Mutant::Env do context '#kill' do let(:object) do described_class.new( - config: config, actor_env: Mutant::Actor::Env.new(Thread), - parser: Mutant::Parser.new, + config: config, + integration: integration, + matchable_scopes: [], + mutations: [], selector: selector, subjects: [], - mutations: [], - matchable_scopes: [], - integration: integration + parser: Mutant::Parser.new ) end @@ -32,8 +32,8 @@ RSpec.describe Mutant::Env do let(:mutation_subject) do instance_double( Mutant::Subject, - identification: 'subject', context: context, + identification: 'subject', source: 'original' ) end @@ -90,10 +90,10 @@ RSpec.describe Mutant::Env do let(:test_result) do Mutant::Result::Test.new( - tests: tests, output: 'test-error', passed: false, - runtime: 0.0 + runtime: 0.0, + tests: tests ) end diff --git a/spec/unit/mutant/integration/rspec_spec.rb b/spec/unit/mutant/integration/rspec_spec.rb index 810b5f71..dc8a37fc 100644 --- a/spec/unit/mutant/integration/rspec_spec.rb +++ b/spec/unit/mutant/integration/rspec_spec.rb @@ -172,10 +172,10 @@ RSpec.describe Mutant::Integration::Rspec do it 'should return failed result' do expect(subject).to eql( Mutant::Result::Test.new( - tests: tests, - output: 'the-test-output', - passed: false, - runtime: 0.0 + output: 'the-test-output', + passed: false, + runtime: 0.0, + tests: tests ) ) end @@ -187,10 +187,10 @@ RSpec.describe Mutant::Integration::Rspec do it 'should return passed result' do expect(subject).to eql( Mutant::Result::Test.new( - tests: tests, - output: 'the-test-output', - passed: true, - runtime: 0.0 + output: 'the-test-output', + passed: true, + runtime: 0.0, + tests: tests ) ) end diff --git a/spec/unit/mutant/integration_spec.rb b/spec/unit/mutant/integration_spec.rb index 71dfe25a..c7ffc42c 100644 --- a/spec/unit/mutant/integration_spec.rb +++ b/spec/unit/mutant/integration_spec.rb @@ -32,10 +32,10 @@ RSpec.describe Mutant::Integration::Null do it 'returns test result' do should eql( Mutant::Result::Test.new( - tests: tests, - runtime: 0.0, + output: '', passed: true, - output: '' + runtime: 0.0, + tests: tests ) ) end diff --git a/spec/unit/mutant/matcher/config_spec.rb b/spec/unit/mutant/matcher/config_spec.rb index fb11a040..119a229f 100644 --- a/spec/unit/mutant/matcher/config_spec.rb +++ b/spec/unit/mutant/matcher/config_spec.rb @@ -30,7 +30,7 @@ RSpec.describe Mutant::Matcher::Config do .add(:ignore_expressions, parse_expression('Bar')) end - it { should eql('#') } + it { should eql('#') } end context 'with subject filter' do diff --git a/spec/unit/mutant/parallel/master_spec.rb b/spec/unit/mutant/parallel/master_spec.rb index aea942df..564bf168 100644 --- a/spec/unit/mutant/parallel/master_spec.rb +++ b/spec/unit/mutant/parallel/master_spec.rb @@ -36,11 +36,11 @@ RSpec.describe Mutant::Parallel::Master do let(:config) do Mutant::Parallel::Config.new( - jobs: 1, env: actor_env, - source: Mutant::Parallel::Source::Array.new([job_payload_a, job_payload_b]), + jobs: 1, + processor: processor, sink: sink, - processor: processor + source: Mutant::Parallel::Source::Array.new([job_payload_a, job_payload_b]) ) end diff --git a/spec/unit/mutant/runner/sink_spec.rb b/spec/unit/mutant/runner/sink_spec.rb index f245d671..e49aa988 100644 --- a/spec/unit/mutant/runner/sink_spec.rb +++ b/spec/unit/mutant/runner/sink_spec.rb @@ -43,7 +43,11 @@ describe Mutant::Runner::Sink do context 'no results' do let(:expected_status) do - Mutant::Result::Env.new(env: env, runtime: 0.0, subject_results: []) + Mutant::Result::Env.new( + env: env, + runtime: 0.0, + subject_results: [] + ) end it { should eql(expected_status) } @@ -55,7 +59,11 @@ describe Mutant::Runner::Sink do with(:subject_a_result) { { mutation_results: [mutation_a_result] } } let(:expected_status) do - Mutant::Result::Env.new(env: env, runtime: 0.0, subject_results: [subject_a_result]) + Mutant::Result::Env.new( + env: env, + runtime: 0.0, + subject_results: [subject_a_result] + ) end it { should eql(expected_status) } @@ -65,7 +73,11 @@ describe Mutant::Runner::Sink do include_context 'two results' let(:expected_status) do - Mutant::Result::Env.new(env: env, runtime: 0.0, subject_results: [subject_a_result]) + Mutant::Result::Env.new( + env: env, + runtime: 0.0, + subject_results: [subject_a_result] + ) end it { should eql(expected_status) } diff --git a/spec/unit/mutant/runner_spec.rb b/spec/unit/mutant/runner_spec.rb index 4526a9f6..f1bdb334 100644 --- a/spec/unit/mutant/runner_spec.rb +++ b/spec/unit/mutant/runner_spec.rb @@ -12,8 +12,8 @@ RSpec.describe Mutant::Runner do instance_double( Mutant::Config, integration: integration, - reporter: reporter, - jobs: 1 + jobs: 1, + reporter: reporter ) end @@ -24,11 +24,11 @@ RSpec.describe Mutant::Runner do let(:parallel_config) do Mutant::Parallel::Config.new( - jobs: 1, env: actor_env, - source: Mutant::Parallel::Source::Array.new(env.mutations), + jobs: 1, + processor: ->(_object) { fail }, sink: Mutant::Runner::Sink.new(env), - processor: ->(_object) { fail } + source: Mutant::Parallel::Source::Array.new(env.mutations) ) end