Skip to content

Commit

Permalink
Update anima to ~0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj committed Sep 4, 2015
1 parent 3874b3f commit 22ac0c8
Show file tree
Hide file tree
Showing 28 changed files with 77 additions and 75 deletions.
2 changes: 1 addition & 1 deletion config/flay.yml
@@ -1,3 +1,3 @@
---
threshold: 18
total_score: 1223
total_score: 1234
22 changes: 11 additions & 11 deletions lib/mutant/cli.rb
Expand Up @@ -98,7 +98,7 @@ def parse_match_expressions(expressions)
def add_environment_options(opts)
opts.separator('Environment:')
opts.on('--zombie', 'Run mutant zombified') do
update(zombie: true)
with(zombie: true)
end
opts.on('-I', '--include DIRECTORY', 'Add DIRECTORY to $LOAD_PATH') do |directory|
add(:includes, directory)
Expand All @@ -107,7 +107,7 @@ def add_environment_options(opts)
add(:requires, name)
end
opts.on('-j', '--jobs NUMBER', 'Number of kill jobs. Defaults to number of processors.') do |number|
update(jobs: Integer(number))
with(jobs: Integer(number))
end
end

Expand All @@ -119,7 +119,7 @@ def add_environment_options(opts)
#
# @api private
def setup_integration(name)
update(integration: Integration.setup(name))
with(integration: Integration.setup(name))
rescue LoadError
raise Error, "Could not load integration #{name.inspect} (you may want to try installing the gem mutant-#{name})"
end
Expand All @@ -139,7 +139,7 @@ def add_mutation_options(opts)
'--expected-coverage COVERAGE',
'Fail unless COVERAGE is not reached exactly, parsed via Rational()'
) do |coverage|
update(expected_coverage: Rational(coverage))
with(expected_coverage: Rational(coverage))
end
opts.on('--use INTEGRATION', 'Use INTEGRATION to kill mutations', &method(:setup_integration))
end
Expand Down Expand Up @@ -169,30 +169,30 @@ def add_filter_options(opts)
# @api private
def add_debug_options(opts)
opts.on('--fail-fast', 'Fail fast') do
update(fail_fast: true)
with(fail_fast: true)
end
opts.on('--version', 'Print mutants version') do
puts("mutant-#{VERSION}")
Kernel.exit(EXIT_SUCCESS)
end
opts.on('-d', '--debug', 'Enable debugging output') do
update(debug: true)
with(debug: true)
end
opts.on_tail('-h', '--help', 'Show this message') do
puts(opts.to_s)
Kernel.exit(EXIT_SUCCESS)
end
end

# Update configuration
# With configuration
#
# @param [Hash<Symbol, Object>] attributes
#
# @return [undefined]
#
# @api private
def update(attributes)
@config = @config.update(attributes)
def with(attributes)
@config = @config.with(attributes)
end

# Add configuration
Expand All @@ -207,7 +207,7 @@ def update(attributes)
#
# @api private
def add(attribute, value)
update(attribute => config.public_send(attribute) + [value])
with(attribute => config.public_send(attribute) + [value])
end

# Add matcher configuration
Expand All @@ -222,7 +222,7 @@ def add(attribute, value)
#
# @api private
def add_matcher(attribute, value)
update(matcher: config.matcher.add(attribute, value))
with(matcher: config.matcher.add(attribute, value))
end

end # CLI
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/config.rb
Expand Up @@ -4,7 +4,7 @@ module Mutant
# Does not reference any "external" volatile state. The configuration applied
# to current environment is being represented by the Mutant::Env object.
class Config
include Adamantium::Flat, Anima::Update, Anima.new(
include Adamantium::Flat, Anima.new(
:debug,
:integration,
:matcher,
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/env.rb
@@ -1,7 +1,7 @@
module Mutant
# Abstract base class for mutant environments
class Env
include Adamantium::Flat, Anima::Update, Anima.new(
include Adamantium::Flat, Anima.new(
:config,
:actor_env,
:cache,
Expand Down
4 changes: 2 additions & 2 deletions lib/mutant/matcher/config.rb
Expand Up @@ -2,7 +2,7 @@ module Mutant
class Matcher
# Subject matcher configuration
class Config
include Adamantium, Anima::Update, Anima.new(
include Adamantium, Anima.new(
:match_expressions,
:ignore_expressions,
:subject_filters
Expand Down Expand Up @@ -41,7 +41,7 @@ def inspect
#
# @api private
def add(attribute, value)
update(attribute => public_send(attribute) + [value])
with(attribute => public_send(attribute) + [value])
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/mutant/parallel.rb
Expand Up @@ -75,12 +75,12 @@ class JobResult

# Parallel run configuration
class Config
include Anima::Update, Adamantium::Flat, Anima.new(:env, :processor, :source, :sink, :jobs)
include Adamantium::Flat, Anima.new(:env, :processor, :source, :sink, :jobs)
end # Config

# Parallel execution status
class Status
include Adamantium::Flat, Anima::Update, Anima.new(:payload, :done, :active_jobs)
include Adamantium::Flat, Anima.new(:payload, :done, :active_jobs)
end

end # Parallel
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/result.rb
Expand Up @@ -67,7 +67,7 @@ def overhead
# @api private
def self.included(host)
host.class_eval do
include Adamantium, Anima::Update
include Adamantium
extend ClassMethods
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mutant/runner/sink.rb
Expand Up @@ -78,7 +78,7 @@ def result(mutation_result)

original = @subject_results[mutation.subject]

@subject_results[mutation.subject] = original.update(
@subject_results[mutation.subject] = original.with(
mutation_results: (original.mutation_results + [mutation_result]),
tests: mutation_result.test_result.tests
)
Expand Down
4 changes: 2 additions & 2 deletions mutant.gemspec
Expand Up @@ -25,15 +25,15 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency('ast', '~> 2.1')
gem.add_runtime_dependency('diff-lcs', '~> 1.2')
gem.add_runtime_dependency('parallel', '~> 1.3')
gem.add_runtime_dependency('morpher', '~> 0.2.4')
gem.add_runtime_dependency('morpher', '~> 0.2.5')
gem.add_runtime_dependency('procto', '~> 0.0.2')
gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
gem.add_runtime_dependency('unparser', '~> 0.2.4')
gem.add_runtime_dependency('ice_nine', '~> 0.11.1')
gem.add_runtime_dependency('adamantium', '~> 0.2.0')
gem.add_runtime_dependency('memoizable', '~> 0.4.2')
gem.add_runtime_dependency('equalizer', '~> 0.0.9')
gem.add_runtime_dependency('anima', '~> 0.2.0')
gem.add_runtime_dependency('anima', '~> 0.3.0')
gem.add_runtime_dependency('concord', '~> 0.1.5')

gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -33,7 +33,7 @@
require 'test_app'

module Fixtures
TEST_CONFIG = Mutant::Config::DEFAULT.update(reporter: Mutant::Reporter::Trace.new)
TEST_CONFIG = Mutant::Config::DEFAULT.with(reporter: Mutant::Reporter::Trace.new)
TEST_CACHE = Mutant::Cache.new
TEST_ENV = Mutant::Env::Bootstrap.(TEST_CONFIG, TEST_CACHE)
end # Fixtures
Expand Down
10 changes: 5 additions & 5 deletions spec/support/shared_context.rb
@@ -1,8 +1,8 @@
# rubocop:disable ModuleLength
module SharedContext
def update(name, &block)
def with(name, &block)
define_method(name) do
super().update(instance_eval(&block))
super().with(instance_eval(&block))
end
end

Expand Down Expand Up @@ -51,7 +51,7 @@ def setup_shared_context
end

let(:config) do
Mutant::Config::DEFAULT.update(
Mutant::Config::DEFAULT.with(
jobs: 1,
reporter: Mutant::Reporter::Trace.new
)
Expand Down Expand Up @@ -120,11 +120,11 @@ def setup_shared_context
end

let(:empty_subject_a_result) do
subject_a_result.update(mutation_results: [])
subject_a_result.with(mutation_results: [])
end

let(:partial_subject_a_result) do
subject_a_result.update(mutation_results: [mutation_a_result])
subject_a_result.with(mutation_results: [mutation_a_result])
end
end
end
6 changes: 3 additions & 3 deletions spec/unit/mutant/cli_spec.rb
Expand Up @@ -73,7 +73,7 @@

let(:default_matcher_config) do
Mutant::Matcher::Config::DEFAULT
.update(match_expressions: expressions.map(&method(:parse_expression)))
.with(match_expressions: expressions.map(&method(:parse_expression)))
end

let(:flags) { [] }
Expand Down Expand Up @@ -235,7 +235,7 @@
let(:flags) { %w[--since master] }

let(:expected_matcher_config) do
default_matcher_config.update(
default_matcher_config.with(
subject_filters: [
Mutant::Repository::SubjectFilter.new(Mutant::Repository::Diff.new('HEAD', 'master'))
]
Expand All @@ -249,7 +249,7 @@
let(:flags) { %w[--ignore-subject Foo::Bar] }

let(:expected_matcher_config) do
default_matcher_config.update(ignore_expressions: [parse_expression('Foo::Bar')])
default_matcher_config.with(ignore_expressions: [parse_expression('Foo::Bar')])
end

it_should_behave_like 'a cli parser'
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/mutant/env/boostrap_spec.rb
@@ -1,6 +1,6 @@
RSpec.describe Mutant::Env::Bootstrap do
let(:config) do
Mutant::Config::DEFAULT.update(
Mutant::Config::DEFAULT.with(
jobs: 1,
reporter: Mutant::Reporter::Trace.new,
includes: [],
Expand Down Expand Up @@ -69,7 +69,7 @@ def name
end

context 'when includes are present' do
let(:config) { super().update(includes: %w[foo bar]) }
let(:config) { super().with(includes: %w[foo bar]) }

before do
%w[foo bar].each do |component|
Expand Down Expand Up @@ -121,7 +121,7 @@ def name
end

let(:expected_env) do
super().update(
super().with(
subjects: subjects,
mutations: mutations
)
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mutant/env_spec.rb
Expand Up @@ -16,7 +16,7 @@
let(:integration) { integration_class.new(config) }

let(:config) do
Mutant::Config::DEFAULT.update(isolation: isolation, integration: integration_class)
Mutant::Config::DEFAULT.with(isolation: isolation, integration: integration_class)
end

let(:isolation) { double('Isolation') }
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mutant/matcher/compiler_spec.rb
Expand Up @@ -18,7 +18,7 @@
end

describe '.call' do
subject { object.call(env, matcher_config.update(attributes)) }
subject { object.call(env, matcher_config.with(attributes)) }

let(:matcher_config) { Mutant::Matcher::Config::DEFAULT }

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/mutant/parallel/master_spec.rb
Expand Up @@ -92,8 +92,8 @@ def stop?
subject { described_class.call(config) }

context 'with multiple workers configured' do
let(:config) { super().update(jobs: 2) }
let(:expected_results) { [] }
let(:config) { super().with(jobs: 2) }
let(:expected_results) { [] }

before do
expect(Mutant::Parallel::Worker).to receive(:run).with(
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mutant/reporter/cli/printer/config_spec.rb
Expand Up @@ -17,7 +17,7 @@
end

context 'with non default coverage expectation' do
update(:config) { { expected_coverage: 0.1r } }
with(:config) { { expected_coverage: 0.1r } }

it_reports(<<-REPORT)
Mutant configuration:
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb
@@ -1,13 +1,13 @@
RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
setup_shared_context

update(:config) { { expected_coverage: 0.1r } }
with(:config) { { expected_coverage: 0.1r } }

let(:reportable) { env_result }

describe '.call' do
context 'without progress' do
update(:subject_a_result) { { mutation_results: [] } }
with(:subject_a_result) { { mutation_results: [] } }

it_reports <<-'STR'
Mutant configuration:
Expand Down Expand Up @@ -51,7 +51,7 @@
end

context 'on partial coverage' do
update(:mutation_a_test_result) { { passed: true } }
with(:mutation_a_test_result) { { passed: true } }

it_reports <<-'STR'
Mutant configuration:
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/mutant/reporter/cli/printer/env_result_spec.rb
@@ -1,7 +1,7 @@
RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do
setup_shared_context

update(:mutation_a_test_result) { { passed: true } }
with(:mutation_a_test_result) { { passed: true } }

let(:reportable) { env_result }

Expand Down
Expand Up @@ -9,13 +9,13 @@

describe '.run' do
context 'on killed mutant' do
update(:mutation_a_test_result) { { passed: true } }
with(:mutation_a_test_result) { { passed: true } }

it_reports Mutant::Color::RED.format('F')
end

context 'on alive mutant' do
update(:mutation_a_test_result) { { passed: false } }
with(:mutation_a_test_result) { { passed: false } }

it_reports Mutant::Color::GREEN.format('.')
end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb
Expand Up @@ -5,7 +5,7 @@

describe '.call' do
context 'failed kill' do
update(:mutation_a_test_result) { { passed: true } }
with(:mutation_a_test_result) { { passed: true } }

context 'on evil mutation' do
context 'with a diff' do
Expand Down Expand Up @@ -61,7 +61,7 @@
end

context 'on neutral mutation' do
update(:mutation_a_test_result) { { passed: false } }
with(:mutation_a_test_result) { { passed: false } }

let(:mutation_a) do
Mutant::Mutation::Neutral.new(subject_a, s(:true))
Expand All @@ -86,7 +86,7 @@
end

context 'on noop mutation' do
update(:mutation_a_test_result) { { passed: false } }
with(:mutation_a_test_result) { { passed: false } }

let(:mutation_a) do
Mutant::Mutation::Noop.new(subject_a, s(:true))
Expand Down

0 comments on commit 22ac0c8

Please sign in to comment.