mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (ruby_cleanup): exit by SystemExit and SignalException in END
block. [ruby-core:10609] * test/ruby/test_beginendblock.rb (test_should_propagate_exit_code): test for exit in END block. [ruby-core:10760] * test/ruby/test_beginendblock.rb (test_should_propagate_signaled): test for signal in END block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a8ba0adb5c
commit
2898d5c5a8
4 changed files with 53 additions and 8 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Sat Mar 24 01:54:03 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (ruby_cleanup): exit by SystemExit and SignalException in END
|
||||
block. [ruby-core:10609]
|
||||
|
||||
* test/ruby/test_beginendblock.rb (test_should_propagate_exit_code):
|
||||
test for exit in END block. [ruby-core:10760]
|
||||
|
||||
* test/ruby/test_beginendblock.rb (test_should_propagate_signaled):
|
||||
test for signal in END block.
|
||||
|
||||
Thu Mar 22 23:13:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_provided): check for extension library if SOEXT is
|
||||
|
|
14
eval.c
14
eval.c
|
@ -1562,11 +1562,15 @@ ruby_cleanup(ex)
|
|||
int ex;
|
||||
{
|
||||
int state;
|
||||
volatile VALUE err = ruby_errinfo;
|
||||
VALUE err;
|
||||
volatile VALUE errs[2];
|
||||
int nerr;
|
||||
|
||||
errs[0] = ruby_errinfo;
|
||||
ruby_safe_level = 0;
|
||||
Init_stack((void*)&state);
|
||||
ruby_finalize_0();
|
||||
errs[1] = ruby_errinfo;
|
||||
PUSH_TAG(PROT_NONE);
|
||||
PUSH_ITER(ITER_NOT);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
|
@ -1577,15 +1581,15 @@ ruby_cleanup(ex)
|
|||
ex = state;
|
||||
}
|
||||
POP_ITER();
|
||||
ruby_errinfo = err;
|
||||
ruby_errinfo = errs[0];
|
||||
ex = error_handle(ex);
|
||||
ruby_finalize_1();
|
||||
POP_TAG();
|
||||
|
||||
if (err) {
|
||||
for (nerr = sizeof(errs) / sizeof(errs[0]); nerr;) {
|
||||
if (!(err = errs[--nerr])) continue;
|
||||
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
|
||||
VALUE st = rb_iv_get(err, "status");
|
||||
return NUM2INT(st);
|
||||
return sysexit_status(err);
|
||||
}
|
||||
else if (rb_obj_is_kind_of(err, rb_eSignal)) {
|
||||
VALUE sig = rb_iv_get(err, "signo");
|
||||
|
|
|
@ -54,4 +54,34 @@ EOW
|
|||
assert_equal(expected, File.read(erroutpath))
|
||||
# expecting Tempfile to unlink launcher and errout file.
|
||||
end
|
||||
|
||||
def test_raise_in_at_exit
|
||||
# [ruby-core:09675]
|
||||
ruby = EnvUtil.rubybin
|
||||
out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \
|
||||
"at_exit{raise %[SomethingBad]};" \
|
||||
"raise %[SomethingElse]'") {|f|
|
||||
f.read
|
||||
}
|
||||
assert_match /SomethingBad/, out
|
||||
assert_match /SomethingElse/, out
|
||||
end
|
||||
|
||||
def test_should_propagate_exit_code
|
||||
ruby = EnvUtil.rubybin
|
||||
assert_equal false, system("#{q(ruby)} -e 'at_exit{exit 2}'")
|
||||
assert_equal 2, $?.exitstatus
|
||||
assert_nil $?.termsig
|
||||
end
|
||||
|
||||
def test_should_propagate_signaled
|
||||
ruby = EnvUtil.rubybin
|
||||
out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \
|
||||
"at_exit{Process.kill(:INT, $$)}'"){|f|
|
||||
f.read
|
||||
}
|
||||
assert_match /Interrupt$/, out
|
||||
assert_nil $?.exitstatus
|
||||
assert_equal Signal.list["INT"], $?.termsig
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.8.6"
|
||||
#define RUBY_RELEASE_DATE "2007-03-22"
|
||||
#define RUBY_RELEASE_DATE "2007-03-24"
|
||||
#define RUBY_VERSION_CODE 186
|
||||
#define RUBY_RELEASE_CODE 20070322
|
||||
#define RUBY_RELEASE_CODE 20070324
|
||||
#define RUBY_PATCHLEVEL 5000
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 6
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 3
|
||||
#define RUBY_RELEASE_DAY 22
|
||||
#define RUBY_RELEASE_DAY 24
|
||||
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
RUBY_EXTERN const char ruby_release_date[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue