diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-06-30 20:12:17 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-06-30 20:12:17 -0300 |
commit | e5b8c4483c8de805d5847563edcf4e5d7e035a87 (patch) | |
tree | 00f579d40ce23c5ebb0a3386ca5c00d22406bbd6 /activesupport/lib/active_support/testing/isolation.rb | |
parent | 9c70442534c7754eac3738e0ddf11446b01c4f9e (diff) | |
parent | db3de78a83379ab2a58e0d29fb10622b813a4d44 (diff) | |
download | rails-e5b8c4483c8de805d5847563edcf4e5d7e035a87.tar.gz rails-e5b8c4483c8de805d5847563edcf4e5d7e035a87.tar.bz2 rails-e5b8c4483c8de805d5847563edcf4e5d7e035a87.zip |
Merge commit 'rails/master'
Conflicts:
activerecord/lib/active_record/base.rb
Diffstat (limited to 'activesupport/lib/active_support/testing/isolation.rb')
-rw-r--r-- | activesupport/lib/active_support/testing/isolation.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb new file mode 100644 index 0000000000..8b2957fbe1 --- /dev/null +++ b/activesupport/lib/active_support/testing/isolation.rb @@ -0,0 +1,39 @@ +module ActiveSupport::Testing + class ProxyTestResult + def initialize + @calls = [] + end + + def __replay__(result) + @calls.each do |name, args| + result.send(name, *args) + end + end + + def method_missing(name, *args) + @calls << [name, args] + end + end + + module Isolation + def run(result) + yield(Test::Unit::TestCase::STARTED, name) + + read, write = IO.pipe + + pid = fork do + # child + read.close + proxy = ProxyTestResult.new + super(proxy) { } + write.puts [Marshal.dump(proxy)].pack("m") + exit! + end + + write.close + Marshal.load(read.read.unpack("m")[0]).__replay__(result) + Process.wait2(pid) + yield(Test::Unit::TestCase::FINISHED, name) + end + end +end
\ No newline at end of file |