Bug #5197

at_exit order has changed in 1.9.3dev32413

Added by Ryan Davis over 2 years ago. Updated over 2 years ago.

[ruby-core:38995]
Status:Rejected
Priority:Normal
Assignee:Motohiro KOSAKI
Category:core
Target version:1.9.3
ruby -v:1.9.3dev32413 Backport:

Description

I could have sworn I filed or mailed this before, but I can't find it. Sorry if this is a dupe.

#!/usr/bin/ruby -w

happy = false
atexit { happy = true } # test runner
at
exit { at_exit { abort "not happy!" unless happy } } # after test hook

multiruby produces:

VERSION = mri_trunk

CMD = ~/.multiruby/install/mri_trunk/bin/ruby -v -Ilib bug4.rb

#

ruby 1.9.3dev (2011-07-05 trunk 32413) [x86_64-darwin10.8.0]

not happy!

#

RESULT = 256

#

VERSION = 1.8.7-p330

CMD = ~/.multiruby/install/1.8.7-p330/bin/ruby -v -Ilib bug4.rb

#

ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.5.0]

#

RESULT = 0

#

VERSION = 1.9.2-p136

CMD = ~/.multiruby/install/1.9.2-p136/bin/ruby -v -Ilib bug4.rb

#

ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.5.0]

#

RESULT = 0

#

TOTAL RESULT = 1 failures out of 3

History

#1 Updated by Motohiro KOSAKI over 2 years ago

Hi Ryan,

Can you please see following discussion at first?

http://redmine.ruby-lang.org/issues/4400

And then, can you please explain why you are unhappy? Now at_exit() is consistent with JRuby and MacRuby. Then, fixing your unhappiness need to change three Ruby implementation at least.

Thanks.

#2 Updated by Motohiro KOSAKI over 2 years ago

  • Status changed from Open to Feedback
  • Assignee set to Ryan Davis

#3 Updated by Ryan Davis over 2 years ago

  • Assignee changed from Ryan Davis to Motohiro KOSAKI

That discussion makes my head hurt.

What I need is this:

1) minitest, like test/unit before it, runs its tests via at_exit.
2) Users need to be able to register code to run AFTER the tests run (for extra reporting, or resource cleanup). This was usually done with:

at_exit { at_exit { codes } }

which I wrapped up in a method called #after_tests(&b).

Now that doesn't work. I need some mechanism to make this work as its been available this way for 10+ years. I don't care what mechanism I wind up using, as long as it works.

See https://github.com/seattlerb/minitest/issues/25 for more info.

#4 Updated by Motohiro KOSAKI over 2 years ago

  • Status changed from Feedback to Rejected

What I need is this:

1) minitest, like test/unit before it, runs its tests via at_exit.
2) Users need to be able to register code to run AFTER the tests run (for extra reporting, or > resource cleanup). This was usually done with:

atexit { atexit { codes } }

Yeah, It's clearly bad code.

quote from . Matz wrote,

OK, I choose C's behavior. Although I don't recommend to rely too
much on the atexit order. Motohiro, could you check in?

I'm stand aside matz. don't do that.

which I wrapped up in a method called #after_tests(&b).

Now that doesn't work.

Not now. It has been broken long time.
Even if I revert MRI change, It doesn't work on other ruby implementation.

So, I don't understand why we need revert the code even if it doesn't solve the problem.

I need some mechanism to make this work as its been available this way for 10+ years.
I don't care what mechanism I wind up using, as long as it works.

I pity the 10+ years broken code.
And one correction. This behavior was introduced following commit. see date.


commit a3e1b1ce7ed7e7ffac23015fc2fde56511b30681
Author: ko1 ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Date: Sun Dec 31 15:02:22 2006 +0000

    * Merge YARV

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Last of all.
But, as far as that a revert solve a issue, I'd like to choose a revert. Please remember it.

Thanks.

Also available in: Atom PDF