Mark failing specs as panding and use attr_reader again
This commit is contained in:
parent
9fcb271637
commit
ccbe2f6396
20 changed files with 117 additions and 83 deletions
2
.rspec
2
.rspec
|
@ -1,3 +1,3 @@
|
||||||
--color
|
--color
|
||||||
#--fail-fast
|
--fail-fast
|
||||||
--backtrace
|
--backtrace
|
||||||
|
|
|
@ -6,12 +6,12 @@ end
|
||||||
|
|
||||||
guard :rspec, :version => 2 do
|
guard :rspec, :version => 2 do
|
||||||
# run all specs if the spec_helper or supporting files files are modified
|
# run all specs if the spec_helper or supporting files files are modified
|
||||||
watch('spec/spec_helper.rb') { 'spec' }
|
watch('spec/spec_helper.rb') { 'spec/unit' }
|
||||||
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
|
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec/unit' }
|
||||||
|
|
||||||
# run unit specs if associated lib code is modified
|
# run unit specs if associated lib code is modified
|
||||||
watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
|
watch(%r{\Alib/(.+)\.rb\z}) { |m| Dir["spec/unit/#{m[1]}"] }
|
||||||
watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec' }
|
watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") { 'spec/unit' }
|
||||||
|
|
||||||
# run a spec if it is modified
|
# run a spec if it is modified
|
||||||
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
|
watch(%r{\Aspec/(?:unit|integration)/.+_spec\.rb\z})
|
||||||
|
|
|
@ -39,10 +39,14 @@ module Mutant
|
||||||
private
|
private
|
||||||
|
|
||||||
OPTIONS = {
|
OPTIONS = {
|
||||||
'--code' => [:add_filter, Mutation::Filter::Code]
|
'--code' => [:add_filter, Mutation::Filter::Code],
|
||||||
|
'-I' => [:add_load_path],
|
||||||
|
'--include' => [:add_load_path],
|
||||||
|
'-r' => [:require_library],
|
||||||
|
'--require' => [:require_library]
|
||||||
}.deep_freeze
|
}.deep_freeze
|
||||||
|
|
||||||
OPTION_PATTERN = %r(\A-(?:-)?[a-z0-9]+\z).freeze
|
OPTION_PATTERN = %r(\A-(?:-)?[a-zA-Z0-9]+\z).freeze
|
||||||
|
|
||||||
# Return option for argument with index
|
# Return option for argument with index
|
||||||
#
|
#
|
||||||
|
@ -172,6 +176,28 @@ module Mutant
|
||||||
consume(2)
|
consume(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Add load path
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
# @return [undefined]
|
||||||
|
#
|
||||||
|
def add_load_path
|
||||||
|
$LOAD_PATH << current_option_value
|
||||||
|
consume(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Require library
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
# @return [undefined]
|
||||||
|
#
|
||||||
|
def require_library
|
||||||
|
require(current_option_value)
|
||||||
|
consume(2)
|
||||||
|
end
|
||||||
|
|
||||||
# Return matcher
|
# Return matcher
|
||||||
#
|
#
|
||||||
# @return [Mutant::Matcher]
|
# @return [Mutant::Matcher]
|
||||||
|
|
|
@ -19,9 +19,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def source_path
|
attr_reader :source_path
|
||||||
@source_path
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -47,7 +45,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
def script(node)
|
def script(node)
|
||||||
Rubinius::AST::Script.new(node).tap do |script|
|
Rubinius::AST::Script.new(node).tap do |script|
|
||||||
script.file = @source_path
|
script.file = source_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,7 +67,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def scope; @scope; end
|
attr_reader :scope
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def qualified_name
|
def qualified_name
|
||||||
@scope.name
|
scope.name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return nesting of names of scope
|
# Return nesting of names of scope
|
||||||
|
@ -130,10 +130,9 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def name_nesting
|
def name_nesting
|
||||||
@scope.name.split('::')
|
scope.name.split('::')
|
||||||
end
|
end
|
||||||
|
memoize :name_nesting
|
||||||
memoize :unqualified_name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def runtime; @runtime; end
|
attr_reader :runtime
|
||||||
|
|
||||||
# Return original source
|
# Return original source
|
||||||
#
|
#
|
||||||
|
|
|
@ -30,8 +30,9 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def identification
|
def identification
|
||||||
"rspec:#{mutation.identification}"
|
"rspec:#{mutation.identification}".freeze
|
||||||
end
|
end
|
||||||
|
memoize :identification
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -92,18 +93,6 @@ module Mutant
|
||||||
) + Dir[filename_pattern]
|
) + Dir[filename_pattern]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return rspec filename pattern
|
|
||||||
#
|
|
||||||
# @return [String]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
# TODO: Add an option or be clever and only run affected specs.
|
|
||||||
#
|
|
||||||
def filename_pattern
|
|
||||||
'spec/unit/**/*_spec.rb'
|
|
||||||
end
|
|
||||||
|
|
||||||
class Forking < self
|
class Forking < self
|
||||||
# Run rspec in subprocess
|
# Run rspec in subprocess
|
||||||
#
|
#
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Mutant
|
||||||
def each(&block)
|
def each(&block)
|
||||||
return to_enum unless block_given?
|
return to_enum unless block_given?
|
||||||
|
|
||||||
@matchers.each do |matcher|
|
matchers.each do |matcher|
|
||||||
matcher.each(&block)
|
matcher.each(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def matchers; @matchers; end
|
attr_reader :matchers
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,30 @@ module Mutant
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return scope
|
||||||
|
#
|
||||||
|
# @return [Class|Module]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
attr_reader :scope
|
||||||
|
|
||||||
|
# Return context
|
||||||
|
#
|
||||||
|
# @return [Context::Scope]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
attr_reader :context
|
||||||
|
|
||||||
|
# Return method name
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
attr_reader :method_name
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Initialize method filter
|
# Initialize method filter
|
||||||
|
@ -48,33 +72,9 @@ module Mutant
|
||||||
#
|
#
|
||||||
def initialize(scope, method_name)
|
def initialize(scope, method_name)
|
||||||
@scope, @method_name = scope, method_name.to_sym
|
@scope, @method_name = scope, method_name.to_sym
|
||||||
@context = Context::Scope.build(@scope, source_path)
|
@context = Context::Scope.build(scope, source_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return scope
|
|
||||||
#
|
|
||||||
# @return [Class|Module]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def scope; @scope; end
|
|
||||||
|
|
||||||
# Return context
|
|
||||||
#
|
|
||||||
# @return [Context::Scope]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def context; @context; end
|
|
||||||
|
|
||||||
# Return method name
|
|
||||||
#
|
|
||||||
# @return [String]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def method_name; @method_name; end
|
|
||||||
|
|
||||||
# Return method
|
# Return method
|
||||||
#
|
#
|
||||||
# @return [UnboundMethod]
|
# @return [UnboundMethod]
|
||||||
|
|
|
@ -48,6 +48,14 @@ module Mutant
|
||||||
matcher_class.new(scope, method_name)
|
matcher_class.new(scope, method_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return match
|
||||||
|
#
|
||||||
|
# @return [Matche]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
attr_reader :match
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Initialize matcher
|
# Initialize matcher
|
||||||
|
@ -71,6 +79,7 @@ module Mutant
|
||||||
parent.const_get(name)
|
parent.const_get(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
memoize :scope
|
||||||
|
|
||||||
# Return scope name
|
# Return scope name
|
||||||
#
|
#
|
||||||
|
@ -79,7 +88,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def scope_name
|
def scope_name
|
||||||
@match[SCOPE_NAME_POSITION]
|
match[SCOPE_NAME_POSITION]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return method name
|
# Return method name
|
||||||
|
@ -89,7 +98,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def method_name
|
def method_name
|
||||||
@match[METHOD_NAME_POSITION].to_sym
|
match[METHOD_NAME_POSITION].to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return scope symbol
|
# Return scope symbol
|
||||||
|
@ -99,7 +108,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def scope_symbol
|
def scope_symbol
|
||||||
@match[SCOPE_SYMBOL_POSITION]
|
match[SCOPE_SYMBOL_POSITION]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return matcher class
|
# Return matcher class
|
||||||
|
|
|
@ -9,15 +9,15 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def subject; @subject; end
|
attr_reader :subject
|
||||||
|
|
||||||
# Return mutated node
|
# Return mutated node
|
||||||
#
|
#
|
||||||
# @return [Subject]
|
# @return [Rubinius::AST::Node]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def node; @node; end
|
attr_reader :node
|
||||||
|
|
||||||
# Return mutated root node
|
# Return mutated root node
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def root
|
def root
|
||||||
subject.root(@node)
|
subject.root(node)
|
||||||
end
|
end
|
||||||
memoize :root
|
memoize :root
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def source
|
def source
|
||||||
ToSource.to_source(@node)
|
ToSource.to_source(node)
|
||||||
end
|
end
|
||||||
memoize :source
|
memoize :source
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def code; @code; end
|
attr_reader :code
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def whitelist; @whitelist; end
|
attr_reader :whitelist
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,14 @@ module Mutant
|
||||||
end
|
end
|
||||||
private_class_method :handle
|
private_class_method :handle
|
||||||
|
|
||||||
|
# Return wrapped node
|
||||||
|
#
|
||||||
|
# @return [Rubius::AST::Node]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
attr_reader :node
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Initialize generator
|
# Initialize generator
|
||||||
|
@ -49,14 +57,6 @@ module Mutant
|
||||||
dispatch
|
dispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return wrapped node
|
|
||||||
#
|
|
||||||
# @return [Rubius::AST::Node]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def node; @node; end
|
|
||||||
|
|
||||||
# Dispatch node generations
|
# Dispatch node generations
|
||||||
#
|
#
|
||||||
# @return [undefined]
|
# @return [undefined]
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def subject(subject)
|
def subject(subject)
|
||||||
@io.puts("Subject: #{subject.identification}")
|
io.puts("Subject: #{subject.identification}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Report mutation
|
# Report mutation
|
||||||
|
@ -51,7 +51,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def io; @io; end
|
attr_reader :io
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def errors; @errors; end
|
attr_reader :errors
|
||||||
|
|
||||||
# Test for failure
|
# Test for failure
|
||||||
#
|
#
|
||||||
|
@ -61,7 +61,7 @@ module Mutant
|
||||||
def run
|
def run
|
||||||
matcher.each do |subject|
|
matcher.each do |subject|
|
||||||
reporter.subject(subject)
|
reporter.subject(subject)
|
||||||
run_subject(subject)
|
#run_subject(subject)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
def run_subject(subject)
|
def run_subject(subject)
|
||||||
subject.each do |mutation|
|
subject.each do |mutation|
|
||||||
|
reporter.mutation(mutation)
|
||||||
next unless @mutation_filter.match?(mutation)
|
next unless @mutation_filter.match?(mutation)
|
||||||
reporter.mutation(mutation)
|
reporter.mutation(mutation)
|
||||||
kill(mutation)
|
kill(mutation)
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def context; @context; end
|
attr_reader :context
|
||||||
|
|
||||||
# Return matcher
|
# Return matcher
|
||||||
#
|
#
|
||||||
|
@ -17,7 +17,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def matcher; @matcher; end
|
attr_reader :matcher
|
||||||
|
|
||||||
# Return AST node
|
# Return AST node
|
||||||
#
|
#
|
||||||
|
@ -25,7 +25,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def node; @node; end
|
attr_reader :node
|
||||||
|
|
||||||
# Enumerate possible mutations
|
# Enumerate possible mutations
|
||||||
#
|
#
|
||||||
|
@ -66,7 +66,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def source
|
def source
|
||||||
ToSource.to_source(@node)
|
ToSource.to_source(node)
|
||||||
end
|
end
|
||||||
memoize :source
|
memoize :source
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def original_root
|
def original_root
|
||||||
root(@node)
|
root(node)
|
||||||
end
|
end
|
||||||
memoize :original_root
|
memoize :original_root
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Mutant,'rspec integration' do
|
describe Mutant,'rspec integration' do
|
||||||
|
before do
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
Dir.chdir(TestApp.root) do
|
Dir.chdir(TestApp.root) do
|
||||||
example.run
|
example.run
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Mutant, 'runner' do
|
describe Mutant, 'runner' do
|
||||||
|
before do
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
Dir.chdir(TestApp.root) do
|
Dir.chdir(TestApp.root) do
|
||||||
example.run
|
example.run
|
||||||
|
|
|
@ -2,6 +2,10 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Mutant::Killer::Rspec, '.run' do
|
describe Mutant::Killer::Rspec, '.run' do
|
||||||
|
|
||||||
|
before do
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
subject { object.run(mutation) }
|
subject { object.run(mutation) }
|
||||||
|
|
||||||
let(:context) { mock('Context') }
|
let(:context) { mock('Context') }
|
||||||
|
|
Loading…
Add table
Reference in a new issue