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(
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

View file

@ -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|

View file

@ -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

View file

@ -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

View file

@ -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(

View file

@ -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(

View file

@ -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

View file

@ -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

View file

@ -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))

View file

@ -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

View file

@ -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

View file

@ -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
#

View file

@ -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

View file

@ -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

View file

@ -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
#

View file

@ -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

View file

@ -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

View file

@ -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
)
)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -30,7 +30,7 @@ RSpec.describe Mutant::Matcher::Config do
.add(:ignore_expressions, parse_expression('Bar'))
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
context 'with subject filter' do

View file

@ -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

View file

@ -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) }

View file

@ -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