aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/test_case.rb1
-rw-r--r--activesupport/lib/active_support/testing/isolation.rb39
2 files changed, 40 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index bab2a401eb..e99a4854ce 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -13,6 +13,7 @@ require 'active_support/testing/assertions'
require 'active_support/testing/deprecation'
require 'active_support/testing/declarative'
require 'active_support/testing/pending'
+require 'active_support/testing/isolation'
module ActiveSupport
class TestCase < ::Test::Unit::TestCase
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