1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #11712 from atambo/activesupport_testing_isolation_jruby

Fix ActiveSupport::Testing::Isolation on jruby
This commit is contained in:
Rafael Mendonça França 2013-08-02 14:45:35 -07:00
commit fd20f2e3c0

View file

@ -3,49 +3,6 @@ require 'minitest/parallel_each'
module ActiveSupport module ActiveSupport
module Testing module Testing
class RemoteError < StandardError
attr_reader :message, :backtrace
def initialize(exception)
@message = "caught #{exception.class.name}: #{exception.message}"
@backtrace = exception.backtrace
end
end
class ProxyTestResult
def initialize(calls = [])
@calls = calls
end
def add_error(e)
e = Test::Unit::Error.new(e.test_name, RemoteError.new(e.exception))
@calls << [:add_error, e]
end
def __replay__(result)
@calls.each do |name, args|
result.send(name, *args)
end
end
def marshal_dump
@calls
end
def marshal_load(calls)
initialize(calls)
end
def method_missing(name, *args)
@calls << [name, args]
end
def info_signal
Signal.list['INFO']
end
end
module Isolation module Isolation
require 'thread' require 'thread'
@ -107,19 +64,18 @@ module ActiveSupport
require "tempfile" require "tempfile"
if ENV["ISOLATION_TEST"] if ENV["ISOLATION_TEST"]
proxy = ProxyTestResult.new yield
retval = yield proxy
File.open(ENV["ISOLATION_OUTPUT"], "w") do |file| File.open(ENV["ISOLATION_OUTPUT"], "w") do |file|
file.puts [Marshal.dump([retval, proxy])].pack("m") file.puts [Marshal.dump(self.dup)].pack("m")
end end
exit! exit!
else else
Tempfile.open("isolation") do |tmpfile| Tempfile.open("isolation") do |tmpfile|
ENV["ISOLATION_TEST"] = @method_name ENV["ISOLATION_TEST"] = self.class.name
ENV["ISOLATION_OUTPUT"] = tmpfile.path ENV["ISOLATION_OUTPUT"] = tmpfile.path
load_paths = $-I.map {|p| "-I\"#{File.expand_path(p)}\"" }.join(" ") load_paths = $-I.map {|p| "-I\"#{File.expand_path(p)}\"" }.join(" ")
`#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")} -t\"#{self.class}\"` `#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")}`
ENV.delete("ISOLATION_TEST") ENV.delete("ISOLATION_TEST")
ENV.delete("ISOLATION_OUTPUT") ENV.delete("ISOLATION_OUTPUT")