Test unit problem

Is it me, or is this a Test::Unit bug?

$ cat atest.rb
require ‘test/unit’

class ATest < Test::Unit::TestCase
def test_1
thread = Thread.new {
flunk()
}
thread.join
end
end
$ ruby atest.rb
Loaded suite atest
Started
/usr/local/lib/ruby/site_ruby/1.8/test/unit/testcase.rb:129:in
add_failure': undefined method[]’ for nil (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testcase.rb:70:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:34:inrun’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:in
each' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:inrun’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:34:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:ineach’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/testrunnermediator.rb:53:inrun_suite’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/console/testrunner.rb:77:in
start_mediator' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/console/testrunner.rb:51:instart’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/console/testrunner.rb:26:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:178 from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:176:incall’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:212
from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:162
from atest.rb:4
$

Stephen
± S.D.Sykes - www.stephensykes.com -
ruby -e ‘_=2;"||25~!A59(1A~47!K~#-6<.A~".scan(/./){
putc$&>$`?$/:
+=$&[0]-?4}’

In article 7762c743.0304241328.3bc46521@posting.google.com,

···

haldane jbshaldane@hotmail.com wrote:

Is it me, or is this a Test::Unit bug?

$ cat atest.rb
require ‘test/unit’

class ATest < Test::Unit::TestCase
def test_1
thread = Thread.new {
flunk()
}
thread.join
end
end
$ ruby atest.rb
Loaded suite atest
Started
/usr/local/lib/ruby/site_ruby/1.8/test/unit/testcase.rb:129:in
add_failure': undefined method ’ for nil (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testcase.rb:70:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:34:in run’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:in
each' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:in run’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:34:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:in each’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit/testsuite.rb:33:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/testrunnermediator.rb:53:in run_suite’
from
/usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/console/testrunner.rb:77:in
start_mediator' from /usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/console/testrunner.rb:51:in start’
from
/usr/local/lib/ruby/site_ruby/1.8/test/unit/ui/console/testrunner.rb:26:in
run' from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:178 from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:176:in call’
from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:212
from /usr/local/lib/ruby/site_ruby/1.8/test/unit.rb:162
from atest.rb:4
$

I’m seeing something similar with ruby 1.8 whereas it worked fine with
1.6.x. Could you try running your test under ruby 1.6.x and see what
happens?

What changed in 1.8 that could have broken Test::Unit?

Phil

Is it me, or is this a Test::Unit bug?

$ cat atest.rb
require ‘test/unit’

class ATest < Test::Unit::TestCase
def test_1
thread = Thread.new {
flunk()
}
thread.join
end
end
$ ruby atest.rb

First of all, Stephen, I’m sorry for not replying to your direct mail to
me about this problem. Life is busy and all that… :-/

At this point I’m not sure what’s wrong, and I haven’t had a chance to
dig in to it. You should know that I have done absolutely nothing in the
way of testing the use of Test::Unit with threads, so this could just be
a display of its inherent lack of thread safety. Does anyone else have
experience with doing thread stuff with Test::Unit?

I probably won’t have time to address this real soon, but I will add it
to the to-do list. Of course, if someone were to investigate and figure
out what the problem was, I’d patch things ASAP :wink:

Thanks,

Nathaniel

<:((><

···

haldane [mailto:jbshaldane@hotmail.com] wrote:

RoleModel Software, Inc.
EQUIP VI

Same errors on : ruby 1.6.8 (2002-12-24) [i586-mswin32]

“Phil Tomson” ptkwt@shell1.aracnet.com wrote in message

···

1.6.x. Could you try running your test under ruby 1.6.x and see what
happens?

Hi!

First of all, Stephen, I’m sorry for not replying to your direct mail to
me about this problem. Life is busy and all that… :-/

Ok, sorry for being too hasty, I wasn’t sure if the email address was
active.

I probably won’t have time to address this real soon, but I will add it
to the to-do list. Of course, if someone were to investigate and figure
out what the problem was, I’d patch things ASAP :wink:

It look’s like it’s because Kernel#caller does not return what
testunit is expecting when it is a new thread. Shouldn’t be hard to
fix, I’ll try to come up with a patch.

Stephen.
± S.D.Sykes - www.stephensykes.com -
ruby -e ‘_=2;"||25~!A59(1A~47!K~#-6<.A~".scan(/./){
putc$&>$`?$/:
+=$&[0]-?4}’