Oh look, there's the ruby call I was looking for (exit!)

This commit is contained in:
Chris Eppstein 2009-10-25 20:13:28 -07:00
parent adce6a4873
commit 0e244f21c5
3 changed files with 42 additions and 37 deletions

View File

@ -1,35 +0,0 @@
require 'cucumber/ast/step_invocation'
module Cucumber
module Ast
class StepInvocation #:nodoc:
def invoke(step_mother, options)
find_step_match!(step_mother)
unless @skip_invoke || options[:dry_run] || @exception || @step_collection.exception
@skip_invoke = true
begin
@step_match.invoke(@multiline_arg)
step_mother.after_step
status!(:passed)
rescue Pending => e
failed(options, e, false)
status!(:pending)
rescue Undefined => e
failed(options, e, false)
status!(:undefined)
rescue Cucumber::Ast::Table::Different => e
@different_table = e.table
failed(options, e, false)
status!(:failed)
rescue SystemExit => e
raise
rescue Exception => e
failed(options, e, false)
status!(:failed)
end
end
end
end
end
end

View File

@ -53,14 +53,14 @@ When /^I run in a separate process: compass ([^\s]+) ?(.+)?$/ do |command, args|
open('/tmp/last_error.compass_test.txt', 'w') do |file| open('/tmp/last_error.compass_test.txt', 'w') do |file|
file.puts @stderr.string file.puts @stderr.string
end end
exit # This doesn't exit exit!
end end
# this command will run forever # this command will run forever
# we kill it with a HUP signal from the parent process. # we kill it with a HUP signal from the parent process.
args = (args || '').split args = (args || '').split
args << { :wait => 5 } args << { :wait => 5 }
compass command, *args compass command, *args
exit exit!
end end
end end

40
test/rails_helper.rb Normal file
View File

@ -0,0 +1,40 @@
module Compass
module RailsHelper
def generate_rails_app_directories(name)
Dir.mkdir name
Dir.mkdir File.join(name, "config")
Dir.mkdir File.join(name, "config", "initializers")
end
# Generate a rails application without polluting our current set of requires
# with the rails libraries. This will allow testing against multiple versions of rails
# by manipulating the load path.
def generate_rails_app(name)
if pid = fork
Process.wait(pid)
if $?.exitstatus == 2
raise LoadError, "Couldn't load rails"
elsif $?.exitstatus != 0
raise "Failed to generate rails application."
end
else
begin
require 'rails/version'
require 'rails_generator'
require 'rails_generator/scripts/generate'
Rails::Generator::Base.use_application_sources!
capture_output do
Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new $stdout
Rails::Generator::Scripts::Generate.new.run([name], :generator => 'app')
end
rescue LoadError
Kernel.exit(2)
rescue => e
$stderr.puts e
Kernel.exit!(1)
end
Kernel.exit!(0)
end
end
end
end