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
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
namespace::CLI.run(ARGV)
 | 
			
		||||
Kernel.exit(namespace::CLI.run(ARGV))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
module Mutant
 | 
			
		||||
  class Matcher
 | 
			
		||||
    # Matcher to find AST for method
 | 
			
		||||
    # Matcher for subjects that are a specific method
 | 
			
		||||
    class Method < self
 | 
			
		||||
      include Adamantium::Flat, Equalizer.new(:identification)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,14 +123,6 @@ module Mutant
 | 
			
		|||
        method.source_location
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      # Return matched node
 | 
			
		||||
      #
 | 
			
		||||
      # @return [Rubinis::AST::Node]
 | 
			
		||||
      #
 | 
			
		||||
      # @api private
 | 
			
		||||
      #
 | 
			
		||||
      abstract_method :matched_node
 | 
			
		||||
 | 
			
		||||
      # Return subject
 | 
			
		||||
      #
 | 
			
		||||
      # @return [Subject]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@ describe Mutant, 'method matching' do
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  before do
 | 
			
		||||
    #eval(body, TOPLEVEL_BINDING, __FILE__, 0)
 | 
			
		||||
    eval(body)
 | 
			
		||||
    File.stub(:read => body)
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,6 @@
 | 
			
		|||
require 'spec_helper'
 | 
			
		||||
 | 
			
		||||
describe Mutant,'rspec integration' do
 | 
			
		||||
  before do
 | 
			
		||||
    pending
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  around do |example|
 | 
			
		||||
    Dir.chdir(TestApp.root) do
 | 
			
		||||
| 
						 | 
				
			
			@ -11,23 +8,13 @@ describe Mutant,'rspec integration' do
 | 
			
		|||
    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|
 | 
			
		||||
      subject.each do |mutation|
 | 
			
		||||
        runner =  Mutant::Killer::Rspec.run(mutation)
 | 
			
		||||
        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
 | 
			
		||||
  specify 'allows to kill mutations' do
 | 
			
		||||
    Kernel.system("bundle exec mutant -I lib -r test_app --rspec-dm2 ::TestApp::Literal#string").should be(true)
 | 
			
		||||
  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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										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