Fix ordering of attributes

* Unless there is a good reason against these should be alphabetic
This commit is contained in:
Markus Schirp 2015-11-15 20:13:48 +00:00
parent 9001f5e1f5
commit 84eec1eef3
26 changed files with 177 additions and 109 deletions

View file

@ -192,22 +192,22 @@ module Mutant
DEFAULT = new( DEFAULT = new(
debug: false, 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), expected_coverage: Rational(1),
expression_parser: Expression::Parser.new([ expression_parser: Expression::Parser.new([
Expression::Method, Expression::Method,
Expression::Methods, Expression::Methods,
Expression::Namespace::Exact, Expression::Namespace::Exact,
Expression::Namespace::Recursive 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 # Config
end # Mutant end # Mutant

View file

@ -6,17 +6,17 @@ module Mutant
class Config class Config
include Adamantium::Flat, Anima.new( include Adamantium::Flat, Anima.new(
:debug, :debug,
:expected_coverage,
:expression_parser,
:fail_fast,
:integration, :integration,
:matcher,
:includes, :includes,
:isolation,
:jobs,
:matcher,
:requires, :requires,
:reporter, :reporter,
:isolation, :zombie
:fail_fast,
:jobs,
:zombie,
:expected_coverage,
:expression_parser
) )
%i[fail_fast zombie debug].each do |name| %i[fail_fast zombie debug].each do |name|

View file

@ -2,14 +2,14 @@ module Mutant
# Abstract base class for mutant environments # Abstract base class for mutant environments
class Env class Env
include Adamantium::Flat, Anima.new( include Adamantium::Flat, Anima.new(
:config,
:actor_env, :actor_env,
:parser, :config,
:subjects,
:matchable_scopes,
:integration, :integration,
:matchable_scopes,
:mutations,
:parser,
:selector, :selector,
:mutations :subjects
) )
SEMANTICS_MESSAGE = SEMANTICS_MESSAGE =
@ -53,10 +53,10 @@ module Mutant
end end
rescue Isolation::Error => error rescue Isolation::Error => error
Result::Test.new( Result::Test.new(
tests: tests,
output: error.message, output: error.message,
passed: false,
runtime: Time.now - start, runtime: Time.now - start,
passed: false tests: tests
) )
end end

View file

@ -64,12 +64,12 @@ module Mutant
Env.new( Env.new(
actor_env: Actor::Env.new(Thread), actor_env: Actor::Env.new(Thread),
config: config, config: config,
parser: parser,
subjects: subjects,
matchable_scopes: matchable_scopes,
integration: @integration, integration: @integration,
matchable_scopes: matchable_scopes,
mutations: subjects.flat_map(&:mutations),
parser: parser,
selector: Selector::Expression.new(@integration), selector: Selector::Expression.new(@integration),
mutations: subjects.flat_map(&:mutations) subjects: subjects
) )
end end
@ -91,9 +91,9 @@ module Mutant
rescue => exception rescue => exception
semantics_warning( semantics_warning(
CLASS_NAME_RAISED_EXCEPTION, CLASS_NAME_RAISED_EXCEPTION,
scope_class: scope.class, exception: exception.inspect,
scope: scope, scope: scope,
exception: exception.inspect scope_class: scope.class
) )
nil nil
end end
@ -149,9 +149,9 @@ module Mutant
unless name.instance_of?(String) unless name.instance_of?(String)
semantics_warning( semantics_warning(
CLASS_NAME_TYPE_MISMATCH_FORMAT, CLASS_NAME_TYPE_MISMATCH_FORMAT,
name: name,
scope_class: scope.class, scope_class: scope.class,
scope: scope, scope: scope
name: name
) )
return return
end end

View file

@ -3,7 +3,12 @@ module Mutant
# Explicit method expression # Explicit method expression
class Method < self 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) private(*anima.attribute_names)
MATCHERS = IceNine.deep_freeze( MATCHERS = IceNine.deep_freeze(

View file

@ -3,7 +3,11 @@ module Mutant
# Abstract base class for methods expression # Abstract base class for methods expression
class Methods < self class Methods < self
include Anima.new(:scope_name, :scope_symbol) include Anima.new(
:scope_name,
:scope_symbol
)
private(*anima.attribute_names) private(*anima.attribute_names)
MATCHERS = IceNine.deep_freeze( MATCHERS = IceNine.deep_freeze(

View file

@ -101,10 +101,10 @@ module Mutant
# @api private # @api private
def call(tests) def call(tests)
Result::Test.new( Result::Test.new(
tests: tests,
output: '', output: '',
passed: true,
runtime: 0.0, runtime: 0.0,
passed: true tests: tests
) )
end end

View file

@ -68,10 +68,10 @@ module Mutant
passed = @runner.run_specs(@world.ordered_example_groups).equal?(EXIT_SUCCESS) passed = @runner.run_specs(@world.ordered_example_groups).equal?(EXIT_SUCCESS)
@output.rewind @output.rewind
Result::Test.new( Result::Test.new(
tests: tests,
output: @output.read, output: @output.read,
passed: passed,
runtime: Time.now - start, runtime: Time.now - start,
passed: passed tests: tests
) )
end end
@ -113,8 +113,8 @@ module Mutant
full_description = metadata.fetch(:full_description) full_description = metadata.fetch(:full_description)
Test.new( Test.new(
id: "rspec:#{index}:#{location}/#{full_description}", expression: parse_expression(metadata),
expression: parse_expression(metadata) id: "rspec:#{index}:#{location}/#{full_description}"
) )
end end

View file

@ -3,8 +3,8 @@ module Mutant
# Subject matcher configuration # Subject matcher configuration
class Config class Config
include Adamantium, Anima.new( include Adamantium, Anima.new(
:match_expressions,
:ignore_expressions, :ignore_expressions,
:match_expressions,
:subject_filters :subject_filters
) )
@ -14,8 +14,8 @@ module Mutant
ENUM_DELIMITER = ','.freeze ENUM_DELIMITER = ','.freeze
EMPTY_ATTRIBUTES = 'empty'.freeze EMPTY_ATTRIBUTES = 'empty'.freeze
PRESENTATIONS = IceNine.deep_freeze( PRESENTATIONS = IceNine.deep_freeze(
match_expressions: :syntax,
ignore_expressions: :syntax, ignore_expressions: :syntax,
match_expressions: :syntax,
subject_filters: :inspect subject_filters: :inspect
) )
private_constant(*constants(false)) private_constant(*constants(false))

View file

@ -65,22 +65,38 @@ module Mutant
# Job to push to workers # Job to push to workers
class Job class Job
include Adamantium::Flat, Anima.new(:index, :payload) include Adamantium::Flat, Anima.new(
:index,
:payload
)
end # Job end # Job
# Job result object received from workers # Job result object received from workers
class JobResult class JobResult
include Adamantium::Flat, Anima.new(:job, :payload) include Adamantium::Flat, Anima.new(
:job,
:payload
)
end # JobResult end # JobResult
# Parallel run configuration # Parallel run configuration
class Config class Config
include Adamantium::Flat, Anima.new(:env, :processor, :source, :sink, :jobs) include Adamantium::Flat, Anima.new(
:env,
:jobs,
:processor,
:sink,
:source
)
end # Config end # Config
# Parallel execution status # Parallel execution status
class Status class Status
include Adamantium::Flat, Anima.new(:payload, :done, :active_jobs) include Adamantium::Flat, Anima.new(
:active_jobs,
:done,
:payload
)
end end
end # Parallel end # Parallel

View file

@ -2,7 +2,11 @@ module Mutant
module Parallel module Parallel
# Parallel execution worker # Parallel execution worker
class Worker class Worker
include Adamantium::Flat, Anima.new(:mailbox, :processor, :parent) include Adamantium::Flat, Anima.new(
:mailbox,
:parent,
:processor
)
# Run worker # Run worker
# #
@ -62,7 +66,16 @@ module Mutant
# @api private # @api private
def handle_job(job) def handle_job(job)
result = processor.call(job.payload) 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
end # Worker end # Worker

View file

@ -74,7 +74,11 @@ module Mutant
# Env result object # Env result object
class Env 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 # Test if run is successful
# #
@ -123,16 +127,20 @@ module Mutant
# Test result # Test result
class Test class Test
include Result, Anima.new( include Result, Anima.new(
:tests,
:output, :output,
:passed, :passed,
:runtime :runtime,
:tests
) )
end # Test end # Test
# Subject result # Subject result
class Subject 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 :killtime, :mutation_results
sum :runtime, :mutation_results sum :runtime, :mutation_results
@ -215,7 +223,10 @@ module Mutant
# Mutation result # Mutation result
class Mutation class Mutation
include Result, Anima.new(:mutation, :test_result) include Result, Anima.new(
:mutation,
:test_result
)
# The runtime # The runtime
# #

View file

@ -67,9 +67,9 @@ module Mutant
Parallel::Config.new( Parallel::Config.new(
env: env.actor_env, env: env.actor_env,
jobs: config.jobs, jobs: config.jobs,
source: Parallel::Source::Array.new(env.mutations), processor: env.method(:kill),
sink: Sink.new(env), sink: Sink.new(env),
processor: env.method(:kill) source: Parallel::Source::Array.new(env.mutations)
) )
end end

View file

@ -19,9 +19,9 @@ module Mutant
# @api private # @api private
def expression def expression
Expression::Method.new( Expression::Method.new(
method_name: name.to_s,
scope_symbol: self.class::SYMBOL, scope_symbol: self.class::SYMBOL,
scope_name: scope.name, scope_name: scope.name
method_name: name.to_s
) )
end end
memoize :expression memoize :expression

View file

@ -1,7 +1,10 @@
module Mutant module Mutant
# Abstract base class for test that might kill a mutation # Abstract base class for test that might kill a mutation
class Test class Test
include Adamantium::Flat, Anima.new(:id, :expression) include Adamantium::Flat, Anima.new(
:expression,
:id
)
# Identification string # Identification string
# #

View file

@ -3,13 +3,14 @@ module Mutant
class Zombifier class Zombifier
include Anima.new( include Anima.new(
:includes, :includes,
:namespace,
:load_path, :load_path,
:kernel, :kernel,
:namespace,
:pathname,
:require_highjack, :require_highjack,
:root_require, :root_require
:pathname
) )
private(*anima.attribute_names) private(*anima.attribute_names)
include AST::Sexp include AST::Sexp

View file

@ -16,13 +16,13 @@ module MutantSpec
class Project class Project
MUTEX = Mutex.new MUTEX = Mutex.new
include Adamantium, Anima.new( include Adamantium, Anima.new(
:name,
:repo_uri,
:exclude, :exclude,
:expect_coverage,
:mutation_coverage, :mutation_coverage,
:mutation_generation, :mutation_generation,
:name,
:namespace, :namespace,
:expect_coverage :repo_uri
) )
# Verify mutation coverage # Verify mutation coverage

View file

@ -12,7 +12,10 @@ module MutantSpec
# An event being expected, can advance the VM # An event being expected, can advance the VM
class EventExpectation class EventExpectation
include AbstractType, Anima.new(:expected_payload, :trigger_requires) include AbstractType, Anima.new(
:expected_payload,
:trigger_requires
)
DEFAULTS = IceNine.deep_freeze(trigger_requires: []) DEFAULTS = IceNine.deep_freeze(trigger_requires: [])
@ -56,8 +59,8 @@ module MutantSpec
handle_event( handle_event(
EventObservation.new( EventObservation.new(
EventExpectation::Eval, EventExpectation::Eval,
binding: binding, binding: binding,
source: source, source: source,
source_location: location source_location: location
) )
) )

View file

@ -15,25 +15,25 @@ RSpec.describe Mutant::Env::Bootstrap do
let(:config) do let(:config) do
Mutant::Config::DEFAULT.with( Mutant::Config::DEFAULT.with(
jobs: 1,
reporter: instance_double(Mutant::Reporter),
includes: [], includes: [],
requires: [],
integration: integration_class, integration: integration_class,
matcher: matcher_config jobs: 1,
matcher: matcher_config,
reporter: instance_double(Mutant::Reporter),
requires: []
) )
end end
let(:expected_env) do let(:expected_env) do
Mutant::Env.new( Mutant::Env.new(
parser: Mutant::Parser.new, actor_env: Mutant::Actor::Env.new(Thread),
subjects: [], config: config,
integration: integration,
matchable_scopes: [], matchable_scopes: [],
mutations: [], mutations: [],
config: config, parser: Mutant::Parser.new,
selector: Mutant::Selector::Expression.new(integration), selector: Mutant::Selector::Expression.new(integration),
actor_env: Mutant::Actor::Env.new(Thread), subjects: []
integration: integration
) )
end end
@ -177,8 +177,8 @@ RSpec.describe Mutant::Env::Bootstrap do
Mutant::Scope.new(TestApp::Empty, match_expressions.last), Mutant::Scope.new(TestApp::Empty, match_expressions.last),
Mutant::Scope.new(TestApp::Literal, match_expressions.first) Mutant::Scope.new(TestApp::Literal, match_expressions.first)
], ],
subjects: subjects, mutations: subjects.flat_map(&:mutations),
mutations: subjects.flat_map(&:mutations) subjects: subjects
) )
end end

View file

@ -2,14 +2,14 @@ RSpec.describe Mutant::Env do
context '#kill' do context '#kill' do
let(:object) do let(:object) do
described_class.new( described_class.new(
config: config,
actor_env: Mutant::Actor::Env.new(Thread), actor_env: Mutant::Actor::Env.new(Thread),
parser: Mutant::Parser.new, config: config,
integration: integration,
matchable_scopes: [],
mutations: [],
selector: selector, selector: selector,
subjects: [], subjects: [],
mutations: [], parser: Mutant::Parser.new
matchable_scopes: [],
integration: integration
) )
end end
@ -32,8 +32,8 @@ RSpec.describe Mutant::Env do
let(:mutation_subject) do let(:mutation_subject) do
instance_double( instance_double(
Mutant::Subject, Mutant::Subject,
identification: 'subject',
context: context, context: context,
identification: 'subject',
source: 'original' source: 'original'
) )
end end
@ -90,10 +90,10 @@ RSpec.describe Mutant::Env do
let(:test_result) do let(:test_result) do
Mutant::Result::Test.new( Mutant::Result::Test.new(
tests: tests,
output: 'test-error', output: 'test-error',
passed: false, passed: false,
runtime: 0.0 runtime: 0.0,
tests: tests
) )
end end

View file

@ -172,10 +172,10 @@ RSpec.describe Mutant::Integration::Rspec do
it 'should return failed result' do it 'should return failed result' do
expect(subject).to eql( expect(subject).to eql(
Mutant::Result::Test.new( Mutant::Result::Test.new(
tests: tests, output: 'the-test-output',
output: 'the-test-output', passed: false,
passed: false, runtime: 0.0,
runtime: 0.0 tests: tests
) )
) )
end end
@ -187,10 +187,10 @@ RSpec.describe Mutant::Integration::Rspec do
it 'should return passed result' do it 'should return passed result' do
expect(subject).to eql( expect(subject).to eql(
Mutant::Result::Test.new( Mutant::Result::Test.new(
tests: tests, output: 'the-test-output',
output: 'the-test-output', passed: true,
passed: true, runtime: 0.0,
runtime: 0.0 tests: tests
) )
) )
end end

View file

@ -32,10 +32,10 @@ RSpec.describe Mutant::Integration::Null do
it 'returns test result' do it 'returns test result' do
should eql( should eql(
Mutant::Result::Test.new( Mutant::Result::Test.new(
tests: tests, output: '',
runtime: 0.0,
passed: true, passed: true,
output: '' runtime: 0.0,
tests: tests
) )
) )
end end

View file

@ -30,7 +30,7 @@ RSpec.describe Mutant::Matcher::Config do
.add(:ignore_expressions, parse_expression('Bar')) .add(:ignore_expressions, parse_expression('Bar'))
end end
it { should eql('#<Mutant::Matcher::Config match_expressions: [Foo] ignore_expressions: [Bar]>') } it { should eql('#<Mutant::Matcher::Config ignore_expressions: [Bar] match_expressions: [Foo]>') }
end end
context 'with subject filter' do context 'with subject filter' do

View file

@ -36,11 +36,11 @@ RSpec.describe Mutant::Parallel::Master do
let(:config) do let(:config) do
Mutant::Parallel::Config.new( Mutant::Parallel::Config.new(
jobs: 1,
env: actor_env, env: actor_env,
source: Mutant::Parallel::Source::Array.new([job_payload_a, job_payload_b]), jobs: 1,
processor: processor,
sink: sink, sink: sink,
processor: processor source: Mutant::Parallel::Source::Array.new([job_payload_a, job_payload_b])
) )
end end

View file

@ -43,7 +43,11 @@ describe Mutant::Runner::Sink do
context 'no results' do context 'no results' do
let(:expected_status) 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 end
it { should eql(expected_status) } it { should eql(expected_status) }
@ -55,7 +59,11 @@ describe Mutant::Runner::Sink do
with(:subject_a_result) { { mutation_results: [mutation_a_result] } } with(:subject_a_result) { { mutation_results: [mutation_a_result] } }
let(:expected_status) do 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 end
it { should eql(expected_status) } it { should eql(expected_status) }
@ -65,7 +73,11 @@ describe Mutant::Runner::Sink do
include_context 'two results' include_context 'two results'
let(:expected_status) do 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 end
it { should eql(expected_status) } it { should eql(expected_status) }

View file

@ -12,8 +12,8 @@ RSpec.describe Mutant::Runner do
instance_double( instance_double(
Mutant::Config, Mutant::Config,
integration: integration, integration: integration,
reporter: reporter, jobs: 1,
jobs: 1 reporter: reporter
) )
end end
@ -24,11 +24,11 @@ RSpec.describe Mutant::Runner do
let(:parallel_config) do let(:parallel_config) do
Mutant::Parallel::Config.new( Mutant::Parallel::Config.new(
jobs: 1,
env: actor_env, env: actor_env,
source: Mutant::Parallel::Source::Array.new(env.mutations), jobs: 1,
processor: ->(_object) { fail },
sink: Mutant::Runner::Sink.new(env), sink: Mutant::Runner::Sink.new(env),
processor: ->(_object) { fail } source: Mutant::Parallel::Source::Array.new(env.mutations)
) )
end end