[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

bug in Test Unit?

Nasir Khan

3/12/2008 9:03:00 PM

[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

5 Answers

Ryan Davis

3/13/2008 1:06:00 AM

0


On Mar 12, 2008, at 14:03 , Nasir Khan wrote:

> 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?.


Nasir Khan

3/13/2008 3:34:00 AM

0

[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


On Wed, Mar 12, 2008 at 9:06 PM, Ryan Davis <ryand-ruby@zenspider.com>
wrote:

>
> On Mar 12, 2008, at 14:03 , Nasir Khan wrote:
>
> > 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?.
>
>
>

Phlip

3/13/2008 3:46:00 AM

0

Nasir Khan wrote:

> def self.run=(flag)
> This is obviously not what will happen when at_exit do
> unless $! || Test::Unit.run?

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

See the ? mark?

'run?' ain't the same as 'run=' or 'run()'. Hence, your line gets
pronounced "unless you have an error, or you already ran, you will now
run".

(And, yes, you Inflector detractors, good grammar matters in
programming!;)

--
Phlip
http://assertxpath.ruby...

Jano Svitok

3/13/2008 6:55:00 AM

0

On Thu, Mar 13, 2008 at 4:33 AM, Nasir Khan <rubylearner@gmail.com> wrote:
> 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&...

J.

Nasir Khan

3/13/2008 5:57:00 PM

0

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

Agree. This is how I am using it now.

Thanks
Nasir

On Thu, Mar 13, 2008 at 2:54 AM, Jano Svitok <jan.svitok@gmail.com> wrote:

> On Thu, Mar 13, 2008 at 4:33 AM, Nasir Khan <rubylearner@gmail.com> wrote:
> > 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&...
>
> J.
>
>