mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
The main Thread should have report_on_exception=true for consistency
* Adapt test and add specs. * See [Feature #14143] [ruby-core:84227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
13ea7a8761
commit
2e315baf48
4 changed files with 13 additions and 3 deletions
|
@ -34,6 +34,16 @@ ruby_version_is "2.4" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Thread#report_on_exception" do
|
describe "Thread#report_on_exception" do
|
||||||
|
ruby_version_is "2.5" do
|
||||||
|
it "returns true for the main Thread" do
|
||||||
|
Thread.current.report_on_exception.should == true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns true for new Threads" do
|
||||||
|
Thread.new { Thread.current.report_on_exception }.value.should == true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "returns whether the Thread will print a backtrace if it exits with an exception" do
|
it "returns whether the Thread will print a backtrace if it exits with an exception" do
|
||||||
t = Thread.new { Thread.current.report_on_exception = true }
|
t = Thread.new { Thread.current.report_on_exception = true }
|
||||||
t.join
|
t.join
|
||||||
|
|
|
@ -382,8 +382,8 @@ class TestThread < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal(true, Thread.report_on_exception,
|
assert_equal(true, Thread.report_on_exception,
|
||||||
"global flag is true by default")
|
"global flag is true by default")
|
||||||
assert_equal(false, Thread.current.report_on_exception,
|
assert_equal(true, Thread.current.report_on_exception,
|
||||||
"the main thread has report_on_exception=false")
|
"the main thread has report_on_exception=true")
|
||||||
|
|
||||||
Thread.report_on_exception = true
|
Thread.report_on_exception = true
|
||||||
Thread.current.report_on_exception = false
|
Thread.current.report_on_exception = false
|
||||||
|
|
1
thread.c
1
thread.c
|
@ -743,7 +743,6 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
|
||||||
RBASIC_CLEAR_CLASS(th->pending_interrupt_mask_stack);
|
RBASIC_CLEAR_CLASS(th->pending_interrupt_mask_stack);
|
||||||
|
|
||||||
native_mutex_initialize(&th->interrupt_lock);
|
native_mutex_initialize(&th->interrupt_lock);
|
||||||
th->report_on_exception = th->vm->thread_report_on_exception;
|
|
||||||
|
|
||||||
/* kick thread */
|
/* kick thread */
|
||||||
err = native_thread_create(th);
|
err = native_thread_create(th);
|
||||||
|
|
1
vm.c
1
vm.c
|
@ -2518,6 +2518,7 @@ th_init(rb_thread_t *th, VALUE self)
|
||||||
th->retval = Qundef;
|
th->retval = Qundef;
|
||||||
#endif
|
#endif
|
||||||
th->name = Qnil;
|
th->name = Qnil;
|
||||||
|
th->report_on_exception = th->vm->thread_report_on_exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue