Reconnect API changes for successful spec run
Sorry this looks like spiking around and yeah it was some kind of.
This commit is contained in:
parent
7dfb785ed3
commit
5b3d506523
12 changed files with 79 additions and 44 deletions
|
@ -76,6 +76,16 @@ module Mutant
|
||||||
name_nesting.last
|
name_nesting.last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return name
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def name
|
||||||
|
scope.name
|
||||||
|
end
|
||||||
|
|
||||||
# Return scope wrapped by context
|
# Return scope wrapped by context
|
||||||
#
|
#
|
||||||
# @return [::Module|::Class]
|
# @return [::Module|::Class]
|
||||||
|
@ -105,17 +115,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def root_ast
|
def root_ast
|
||||||
"#{keyword} #{qualified_name}; end".to_ast
|
"#{keyword} #{name}; end".to_ast
|
||||||
end
|
|
||||||
|
|
||||||
# Return qualified name of scope
|
|
||||||
#
|
|
||||||
# @return [String]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def qualified_name
|
|
||||||
scope.name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return nesting of names of scope
|
# Return nesting of names of scope
|
||||||
|
|
|
@ -10,16 +10,16 @@ module Mutant
|
||||||
# Run rspec test
|
# Run rspec test
|
||||||
#
|
#
|
||||||
# @return [true]
|
# @return [true]
|
||||||
# returns true when test is NOT successful and the mutant was killed
|
# when test is NOT successful and the mutant was killed
|
||||||
#
|
#
|
||||||
# @return [false]
|
# @return [false]
|
||||||
# returns false otherwise
|
# otherwise
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def run
|
def run
|
||||||
mutation.insert
|
mutation.insert
|
||||||
!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).zero?
|
!!::RSpec::Core::Runner.run(command_line_arguments, strategy.error_stream, strategy.output_stream).nonzero?
|
||||||
end
|
end
|
||||||
memoize :run
|
memoize :run
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def subject(subject)
|
def subject(_subject)
|
||||||
stats.count_subject
|
stats.count_subject
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -71,7 +71,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def mutation(mutation)
|
def mutation(_mutation)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@ module Mutant
|
||||||
#
|
#
|
||||||
def report_killer(killer)
|
def report_killer(killer)
|
||||||
stats.count_killer(killer)
|
stats.count_killer(killer)
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ module Mutant
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Report config
|
# Report start
|
||||||
#
|
#
|
||||||
# @param [Mutant::Config] config
|
# @param [Mutant::Config] config
|
||||||
#
|
#
|
||||||
|
@ -75,13 +75,24 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def print_config
|
def start(config)
|
||||||
message = []
|
message = []
|
||||||
message << 'Mutant configuration:'
|
message << 'Mutant configuration:'
|
||||||
message << "Matcher: #{config.matcher.inspect}"
|
message << "Matcher: #{config.matcher.inspect}"
|
||||||
message << "Filter: #{config.filter.inspect}"
|
message << "Filter: #{config.filter.inspect}"
|
||||||
message << "Strategy: #{config.strategy.inspect}"
|
message << "Strategy: #{config.strategy.inspect}"
|
||||||
puts message.join("\n")
|
puts message.join("\n")
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
# Report stop
|
||||||
|
#
|
||||||
|
# @return [self]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def stop
|
||||||
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
# Report killer
|
# Report killer
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def run
|
def run
|
||||||
reporter.print_config
|
reporter.start(config)
|
||||||
util = strategy
|
util = strategy
|
||||||
util.setup
|
util.setup
|
||||||
config.matcher.each do |subject|
|
config.matcher.each do |subject|
|
||||||
|
@ -76,7 +76,7 @@ module Mutant
|
||||||
run_subject(subject)
|
run_subject(subject)
|
||||||
end
|
end
|
||||||
util.teardown
|
util.teardown
|
||||||
reporter.print_stats
|
reporter.stop
|
||||||
end
|
end
|
||||||
|
|
||||||
# Run mutation killers on subject
|
# Run mutation killers on subject
|
||||||
|
|
|
@ -6,12 +6,14 @@ module Mutant
|
||||||
|
|
||||||
# Return filename pattern
|
# Return filename pattern
|
||||||
#
|
#
|
||||||
|
# @param [Subject] subject
|
||||||
|
#
|
||||||
# @return [Enumerable<String>]
|
# @return [Enumerable<String>]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def spec_files(mutation)
|
def spec_files(subject)
|
||||||
ExampleLookup.run(mutation)
|
Lookup.run(subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def self.run(subject)
|
def self.run(subject)
|
||||||
new(subject).spec_files
|
build(subject).spec_files
|
||||||
end
|
end
|
||||||
|
|
||||||
REGISTRY = {}
|
REGISTRY = {}
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def base_path
|
def base_path
|
||||||
"spec/unit/#{Inflector.underscore(subject.context_name)}"
|
"spec/unit/#{Inflector.underscore(subject.context.name)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return method name
|
# Return method name
|
||||||
|
@ -35,7 +35,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def method_name
|
def method_name
|
||||||
subject.method_name
|
subject.name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Test if method is public
|
# Test if method is public
|
||||||
|
@ -58,7 +58,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def expanded_name
|
def expanded_name
|
||||||
MethodExpansion.run(subject.method_name)
|
MethodExpansion.run(method_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return glob expression
|
# Return glob expression
|
||||||
|
|
|
@ -15,6 +15,28 @@ module Mutant
|
||||||
#
|
#
|
||||||
abstract_method :public?
|
abstract_method :public?
|
||||||
|
|
||||||
|
# Return method name
|
||||||
|
#
|
||||||
|
# @return [Symbol]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def name
|
||||||
|
node.name
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Return scope
|
||||||
|
#
|
||||||
|
# @return [Class, Module]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def scope
|
||||||
|
context.scope
|
||||||
|
end
|
||||||
|
|
||||||
# Instance method subjects
|
# Instance method subjects
|
||||||
class Instance < self
|
class Instance < self
|
||||||
|
|
||||||
|
@ -29,7 +51,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def public?
|
def public?
|
||||||
scope.public_method_defined?(method_name)
|
scope.public_method_defined?(name)
|
||||||
end
|
end
|
||||||
memoize :public?
|
memoize :public?
|
||||||
|
|
||||||
|
@ -42,7 +64,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def subtype
|
def subtype
|
||||||
"#{context.identification}##{node.name}"
|
"#{context.identification}##{name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -61,7 +83,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def public?
|
def public?
|
||||||
scope.singleton_class.public_method_defined?(method_name)
|
scope.singleton_class.public_method_defined?(name)
|
||||||
end
|
end
|
||||||
memoize :public?
|
memoize :public?
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ describe Mutant::CLI, '.run' do
|
||||||
let(:object) { described_class }
|
let(:object) { described_class }
|
||||||
let(:argv) { mock('ARGV') }
|
let(:argv) { mock('ARGV') }
|
||||||
let(:attributes) { mock('Options') }
|
let(:attributes) { mock('Options') }
|
||||||
let(:runner) { mock('Runner', :fail? => failure) }
|
let(:runner) { mock('Runner', :success? => success) }
|
||||||
let(:instance) { mock(described_class.name, :attributes => attributes) }
|
let(:instance) { mock(described_class.name, :attributes => attributes) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -14,8 +14,8 @@ describe Mutant::CLI, '.run' do
|
||||||
Mutant::Runner.stub(:run => runner)
|
Mutant::Runner.stub(:run => runner)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when runner does NOT fail' do
|
context 'when runner is successful' do
|
||||||
let(:failure) { false }
|
let(:success) { true }
|
||||||
|
|
||||||
it { should be(0) }
|
it { should be(0) }
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ describe Mutant::CLI, '.run' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when runner fails' do
|
context 'when runner fails' do
|
||||||
let(:failure) { true }
|
let(:success) { false }
|
||||||
|
|
||||||
it { should be(1) }
|
it { should be(1) }
|
||||||
|
|
||||||
|
@ -35,4 +35,5 @@ describe Mutant::CLI, '.run' do
|
||||||
should be(1)
|
should be(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,8 @@ describe Mutant::Strategy::Rspec::DM2::Lookup::Method::Instance, '#spec_files' d
|
||||||
subject { object.spec_files }
|
subject { object.spec_files }
|
||||||
|
|
||||||
let(:object) { described_class.new(mutation_subject) }
|
let(:object) { described_class.new(mutation_subject) }
|
||||||
let(:mutation_subject) { mock('Subject', :method_name => method_name, :public? => is_public, :context_name => context_name) }
|
let(:mutation_subject) { mock('Subject', :name => method_name, :public? => is_public, :context => context) }
|
||||||
let(:context_name) { 'Foo' }
|
let(:context) { mock('Context', :name => 'Foo') }
|
||||||
let(:method_name) { :bar }
|
let(:method_name) { :bar }
|
||||||
let(:files) { 'Files'.freeze }
|
let(:files) { 'Files'.freeze }
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ describe Mutant::Strategy::Rspec::DM2::Lookup::Method::Singleton, '#spec_files'
|
||||||
subject { object.spec_files }
|
subject { object.spec_files }
|
||||||
|
|
||||||
let(:object) { described_class.new(mutation_subject) }
|
let(:object) { described_class.new(mutation_subject) }
|
||||||
let(:mutation_subject) { mock('Subject', :method_name => method_name, :public? => is_public, :context_name => context_name) }
|
let(:mutation_subject) { mock('Subject', :name => method_name, :public? => is_public, :context => context) }
|
||||||
let(:context_name) { 'Foo' }
|
|
||||||
let(:method_name) { :bar }
|
let(:method_name) { :bar }
|
||||||
let(:files) { 'Files'.freeze }
|
let(:files) { 'Files'.freeze }
|
||||||
|
let(:context) { mock('Context', :name => 'Foo') }
|
||||||
|
|
||||||
this_example_group = 'Mutant::Strategy::Rspec::DM2::Lookup::Method::Singleton#spec_files'
|
this_example_group = 'Mutant::Strategy::Rspec::DM2::Lookup::Method::Singleton#spec_files'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue