I originally sent this to the jruby list, but did not get any solutions. Has anyone on this side of things had success running jruby inside jython for running ruby unit tests?


(I tried to search the archives, but it wasn't working...)
 
I'm trying to use JRuby in Jython via the JSR-233 engine. The ruby script is a Test::Unit::TestCase originating one and runs from the command line using the regular ruby interpreter. When I try to run it from it from inside my script however, things get ugly. I'm rather confused as to why it is blowing up in the way it is, but realize that it might be something trivial to make it work and having hit the 'spent enough time not figuring it out' its off to the mailing list.
 
So can anyone shed light into the origin of the backtrace or have solved this problem a different way?
 
Note: r.eval('puts "Hello!"') works fine, it is just when I pass in this script that it does not work.
 
Thanks.
 
-adam
http://adam.goucher.ca
 
<ruby>
require 'test/unit'
class ExampleTest < Test::Unit::TestCase
    def test_something
        p "ruby!"
    end
    def test_another
        p "again!"
    end
end
</ruby>
 
<jython>
import javax.script.ScriptContext
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
import javax.script.ScriptException
 
m = javax.script.ScriptEngineManager()
r = m.getEngineByName("jruby")
rs = open(f, "r")
y = r.eval(rs.read())
rs.close()
</jython>
 
<ugliness>
Traceback (innermost last):
  File "jpythonruby.py", line 48, in ?
C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit/autorunner.rb:59: private
 method `sub' called for nil:NilClass (NoMethodError)
        from C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit.rb:2:in `call'
        from C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit/autorunner.rb:198:in `run'
        from C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit/autorunner.rb:13:in `run'
        from C:/temp/jpythonruby/jruby-1.0.2/lib/ruby/1.8/test/unit.rb:278
        from <unknown>:1
        ...internal jruby stack elided...
        from org.jruby.runtime.Block.yield(Block.java:260)
        from org.jruby.runtime.Block.call(Block.java:214)
        from org.jruby.RubyProc.call(RubyProc.java:169)
        from org.jruby.RubyProc.call(RubyProc.java:148)
        from org.jruby.Ruby.tearDown(Ruby.java:1447)
        from org.jruby.javasupport.JavaEmbedUtils.terminate(JavaEmbedUtils.java:66)
        from com.sun.script.jruby.JRubyScriptEngine.evalNode(JRubyScriptEngine.java:396)
        from com.sun.script.jruby.JRubyScriptEngine.eval(JRubyScriptEngine.java:139)
        from javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
        from sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        from sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        from sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        from java.lang.reflect.Method.invoke(Method.java:597)
        from org.python.core.PyReflectedFunction.__call__(Unknown Source)
        from org.python.core.PyMethod.__call__(Unknown Source)
        from org.python.core.PyObject.__call__(Unknown Source)
        from org.python.core.PyInstance.invoke(Unknown Source)
        from org.python.pycode._pyx0.f$0(jpythonruby.py:48)
        from org.python.pycode._pyx0.call_function(jpythonruby.py)
        from org.python.core.PyTableCode.call(Unknown Source)
        from org.python.core.PyCode.call(Unknown Source)
        from org.python.core.Py.runCode(Unknown Source)
        from org.python.core.__builtin__.execfile_flags(Unknown Source)
        from org.python.util.PythonInterpreter.execfile(Unknown Source)
        from org.python.util.jython.main(Unknown Source)
org.jruby.exceptions.RaiseException: org.jruby.exceptions.RaiseException
</ugliness>


Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for free today!


Have fun while connecting on Messenger! Click here to learn more.