From: Tim Pease Date: 2007-05-23T12:24:30+09:00 Subject: Re: test/unit autorun fails to set exit status on failure On 5/22/07, John Carter 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