[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

test/unit autorun fails to set exit status on failure

John Carter

5/23/2007 2:41:00 AM

3 Answers

Tim Pease

5/23/2007 3:25:00 AM

0

On 5/22/07, John Carter <john.carter@tait.co.nz> wrote:
> Consider the elementary unit test that fails...
>
> >
> Bottom line: at_exit seems to be too late (Under ruby-1.8.6 linux
> anyway) to set the exit status.
>

Hmmm ....

$ ruby -v
ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-cygwin]

$ cat tmp.rb
at_exit do
puts "Calling exit handler"
exit 2
end

exit

$ ruby tmp.rb
Calling exit handler

$ echo $?
2


There is nothing in eval.c that prevents the at_exit procs from
calling exit again with a new status code. When the at_exit proc is
called, it is first popped off the stack and then run. When it calls
exit at the end, the whole process starts again, and the next at_exit
proc is called which, too, can call exit with a new status code.

The status passed to the last exit call is the one that is returned.

Is there another at_exit proc that is registered before the Test::Unit
at_ext (and therefore is called afterwards) that is setting the exit
code to zero?

Now, this is all from the 1.8.5 source code. Perhaps something changed
in 1.8.6 -- but that seems a large-ish change.

Blessings,
TwP

Gregory Brown

5/23/2007 3:46:00 AM

0

On 5/22/07, Tim Pease <tim.pease@gmail.com> wrote:

> Now, this is all from the 1.8.5 source code. Perhaps something changed
> in 1.8.6 -- but that seems a large-ish change.

I think this is a bug in 1.8.6:
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=9300&gr...

Tim Pease

5/23/2007 4:15:00 AM

0

On 5/22/07, Gregory Brown <gregory.t.brown@gmail.com> wrote:
> On 5/22/07, Tim Pease <tim.pease@gmail.com> wrote:
>
> > Now, this is all from the 1.8.5 source code. Perhaps something changed
> > in 1.8.6 -- but that seems a large-ish change.
>
> I think this is a bug in 1.8.6:
> http://rubyforge.org/tracker/?func=detail&atid=1698&aid=9300&gr...
>
>

Thanks for the link. Nobu checked in a fix for this bug. Should be
available in the next maintenance release.

TwP