aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-26 09:56:00 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-26 09:56:00 -0300
commit6bcedea2fe958ecebbc250b1dec18120d0c90089 (patch)
treef4ee1283e86da1a8c457fbf196e0df4b967629d9
parent6099b643e6388c23fab40f645544ed4dc478e763 (diff)
parent3136388e550571631d43800a45412788aee55afd (diff)
downloadrails-6bcedea2fe958ecebbc250b1dec18120d0c90089.tar.gz
rails-6bcedea2fe958ecebbc250b1dec18120d0c90089.tar.bz2
rails-6bcedea2fe958ecebbc250b1dec18120d0c90089.zip
Merge pull request #15845 from robin850/jruby-isolation
Make the isolated tests run on JRuby
-rw-r--r--activesupport/lib/active_support/testing/isolation.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb
index 908af176be..68bda35980 100644
--- a/activesupport/lib/active_support/testing/isolation.rb
+++ b/activesupport/lib/active_support/testing/isolation.rb
@@ -70,14 +70,24 @@ module ActiveSupport
exit!
else
Tempfile.open("isolation") do |tmpfile|
- ENV["ISOLATION_TEST"] = self.class.name
- ENV["ISOLATION_OUTPUT"] = tmpfile.path
+ env = {
+ ISOLATION_TEST: self.class.name,
+ ISOLATION_OUTPUT: tmpfile.path
+ }
load_paths = $-I.map {|p| "-I\"#{File.expand_path(p)}\"" }.join(" ")
- `#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")}`
-
- ENV.delete("ISOLATION_TEST")
- ENV.delete("ISOLATION_OUTPUT")
+ orig_args = ORIG_ARGV.join(" ")
+ test_opts = "-n#{self.class.name}##{self.name}"
+ command = "#{Gem.ruby} #{load_paths} #{$0} #{orig_args} #{test_opts}"
+
+ # IO.popen lets us pass env in a cross-platform way
+ child = IO.popen([env, command])
+
+ begin
+ Process.wait(child.pid)
+ rescue Errno::ECHILD # The child process may exit before we wait
+ nil
+ end
return tmpfile.read.unpack("m")[0]
end