Skip to content
This repository
Browse code

Fix ActiveSupport::Testing::Isolation on jruby

Hopefully the first of many related to #11700.

With these changes the railties tests wont 100% pass but at least they
will run and show the errors.

The first problem was the @method_name variable was never set.
This was causing ENV["ISOLATION_TEST"] to always be nil which
would cause the test output to never be written to the tempfile.

The second problem was that an invalid -t option was being passed
to minitest and minitest was erroring out.

The third problem was the run method needs to always return an
instance of the test class it is trying to isolate. We were returning
a ProxyTestResult instead.
  • Loading branch information...
commit 560541ffdecf6240e2cd38d68b841e01bbd654d2 1 parent 5753a8c
Alex Tambellini authored
52  activesupport/lib/active_support/testing/isolation.rb
@@ -3,49 +3,6 @@
3 3
 
4 4
 module ActiveSupport
5 5
   module Testing
6  
-    class RemoteError < StandardError
7  
-
8  
-      attr_reader :message, :backtrace
9  
-
10  
-      def initialize(exception)
11  
-        @message = "caught #{exception.class.name}: #{exception.message}"
12  
-        @backtrace = exception.backtrace
13  
-      end
14  
-    end
15  
-
16  
-    class ProxyTestResult
17  
-      def initialize(calls = [])
18  
-        @calls = calls
19  
-      end
20  
-
21  
-      def add_error(e)
22  
-        e = Test::Unit::Error.new(e.test_name, RemoteError.new(e.exception))
23  
-        @calls << [:add_error, e]
24  
-      end
25  
-
26  
-      def __replay__(result)
27  
-        @calls.each do |name, args|
28  
-          result.send(name, *args)
29  
-        end
30  
-      end
31  
-
32  
-      def marshal_dump
33  
-        @calls
34  
-      end
35  
-
36  
-      def marshal_load(calls)
37  
-        initialize(calls)
38  
-      end
39  
-
40  
-      def method_missing(name, *args)
41  
-        @calls << [name, args]
42  
-      end
43  
-
44  
-      def info_signal
45  
-        Signal.list['INFO']
46  
-      end
47  
-    end
48  
-
49 6
     module Isolation
50 7
       require 'thread'
51 8
 
@@ -107,19 +64,18 @@ def run_in_isolation(&blk)
107 64
           require "tempfile"
108 65
 
109 66
           if ENV["ISOLATION_TEST"]
110  
-            proxy = ProxyTestResult.new
111  
-            retval = yield proxy
  67
+            yield
112 68
             File.open(ENV["ISOLATION_OUTPUT"], "w") do |file|
113  
-              file.puts [Marshal.dump([retval, proxy])].pack("m")
  69
+              file.puts [Marshal.dump(self.dup)].pack("m")
114 70
             end
115 71
             exit!
116 72
           else
117 73
             Tempfile.open("isolation") do |tmpfile|
118  
-              ENV["ISOLATION_TEST"]   = @method_name
  74
+              ENV["ISOLATION_TEST"]   = self.class.name
119 75
               ENV["ISOLATION_OUTPUT"] = tmpfile.path
120 76
 
121 77
               load_paths = $-I.map {|p| "-I\"#{File.expand_path(p)}\"" }.join(" ")
122  
-              `#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")} -t\"#{self.class}\"`
  78
+              `#{Gem.ruby} #{load_paths} #{$0} #{ORIG_ARGV.join(" ")}`
123 79
 
124 80
               ENV.delete("ISOLATION_TEST")
125 81
               ENV.delete("ISOLATION_OUTPUT")

0 notes on commit 560541f

Please sign in to comment.
Something went wrong with that request. Please try again.