bug in Test Unit?

N

Nasir Khan

[Note: parts of this message were removed to make it a legal post.]

In unit.rb with "ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]"

at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run
end
end


if Test::Unit.run is set as false the autorunner will run, if it is set as
true the autorunner will not run.
I don't think this was the intention.

It should read as
unless $! && ! Test::Unit.run?

or (more readable).
if Test::Unit.run? && $!.nil?

Unless I am missing somethig...

Thanks
Nasir
 
R

Ryan Davis

In unit.rb with "ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]"

at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run
end
end

not a bug... just bad English. It should be #ran?, not #run?.
 
N

Nasir Khan

[Note: parts of this message were removed to make it a legal post.]

Well, if you see a few lines above that in unit.rb

module Unit
# If set to false Test::Unit will not automatically run at exit.
def self.run=(flag)
@run = flag
end

Now to me this reads as if you set the flag to true the tests will run on
exit and if set to false the tests will not run on exit.

This is obviously not what will happen when
at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run
end
end

is executed, but the exact opposite.

Nasir


In unit.rb with "ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]"

at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run
end
end

not a bug... just bad English. It should be #ran?, not #run?.
 
J

Jano Svitok

Well, if you see a few lines above that in unit.rb

module Unit
# If set to false Test::Unit will not automatically run at exit.
def self.run=(flag)
@run = flag
end

Now to me this reads as if you set the flag to true the tests will run on
exit and if set to false the tests will not run on exit.

This is obviously not what will happen when

at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run
end
end

is executed, but the exact opposite.

Nasir

This was reported by Slavomir Hudak as rubyforge bug #18041 -- Unit
tests auto-run bug
My solution was to change the comment from "set to false" to "set to true" ;-)

http://rubyforge.org/tracker/index.php?func=detail&aid=18041&group_id=426&atid=1698

J.
 
N

Nasir Khan

[Note: parts of this message were removed to make it a legal post.]

Agree. This is how I am using it now.

Thanks
Nasir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top