Publish exit status of CLI runner in executable
This commit is contained in:
parent
70060caf5d
commit
7a471875fc
6 changed files with 31 additions and 50 deletions
|
|
@ -11,4 +11,4 @@ namespace =
|
||||||
Mutant
|
Mutant
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace::CLI.run(ARGV)
|
Kernel.exit(namespace::CLI.run(ARGV))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
module Mutant
|
module Mutant
|
||||||
class Matcher
|
class Matcher
|
||||||
# Matcher to find AST for method
|
# Matcher for subjects that are a specific method
|
||||||
class Method < self
|
class Method < self
|
||||||
include Adamantium::Flat, Equalizer.new(:identification)
|
include Adamantium::Flat, Equalizer.new(:identification)
|
||||||
|
|
||||||
|
|
@ -123,14 +123,6 @@ module Mutant
|
||||||
method.source_location
|
method.source_location
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return matched node
|
|
||||||
#
|
|
||||||
# @return [Rubinis::AST::Node]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
abstract_method :matched_node
|
|
||||||
|
|
||||||
# Return subject
|
# Return subject
|
||||||
#
|
#
|
||||||
# @return [Subject]
|
# @return [Subject]
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ describe Mutant, 'method matching' do
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
#eval(body, TOPLEVEL_BINDING, __FILE__, 0)
|
||||||
eval(body)
|
eval(body)
|
||||||
File.stub(:read => body)
|
File.stub(:read => body)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
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
|
||||||
|
|
@ -11,23 +8,13 @@ describe Mutant,'rspec integration' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify 'allows to run rspec with mutations' do
|
let(:strategy) { Mutant::Strategy::Rspec::DM2 }
|
||||||
|
|
||||||
Mutant::Matcher::Method.parse('TestApp::Literal#string').each do |subject|
|
specify 'allows to kill mutations' do
|
||||||
subject.each do |mutation|
|
Kernel.system("bundle exec mutant -I lib -r test_app --rspec-dm2 ::TestApp::Literal#string").should be(true)
|
||||||
runner = Mutant::Killer::Rspec.run(mutation)
|
end
|
||||||
runner.fail?.should be(false)
|
|
||||||
end
|
|
||||||
subject.reset
|
|
||||||
end
|
|
||||||
|
|
||||||
Mutant::Matcher::Method.parse('TestApp::Literal#uncovered_string').each do |subject|
|
|
||||||
subject.each do |mutation|
|
|
||||||
runner = Mutant::Killer::Rspec.run(mutation)
|
|
||||||
runner.fail?.should be(true)
|
|
||||||
end
|
|
||||||
subject.reset
|
|
||||||
end
|
|
||||||
|
|
||||||
|
specify 'fails to kill mutations when they are not covered' do
|
||||||
|
Kernel.system("bundle exec mutant -I lib -r test_app --rspec-dm2 ::TestApp::Literal#uncovered_string").should be(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
22
spec/support/rspec.rb
Normal file
22
spec/support/rspec.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Patch rspec to allow nested execution
|
||||||
|
module Rspec
|
||||||
|
# Run block in clean rspec environment
|
||||||
|
#
|
||||||
|
# @return [Object]
|
||||||
|
# returns the value of block
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def self.nest
|
||||||
|
original_world, original_configuration =
|
||||||
|
::RSpec.instance_variable_get(:@world),
|
||||||
|
::RSpec.instance_variable_get(:@configuration)
|
||||||
|
|
||||||
|
::RSpec.reset
|
||||||
|
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
::RSpec.instance_variable_set(:@world, original_world)
|
||||||
|
::RSpec.instance_variable_set(:@configuration, original_configuration)
|
||||||
|
end
|
||||||
|
end
|
||||||
21
stuff.rb
21
stuff.rb
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
# Run block in clean rspec environment
|
|
||||||
#
|
|
||||||
# @return [Object]
|
|
||||||
# returns the value of block
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def self.nest
|
|
||||||
original_world, original_configuration =
|
|
||||||
::RSpec.instance_variable_get(:@world),
|
|
||||||
::RSpec.instance_variable_get(:@configuration)
|
|
||||||
|
|
||||||
::RSpec.reset
|
|
||||||
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
::RSpec.instance_variable_set(:@world, original_world)
|
|
||||||
::RSpec.instance_variable_set(:@configuration, original_configuration)
|
|
||||||
end
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue