[前][次][番号順一覧][スレッド一覧]

ruby-changes:49121

From: eregon <ko1@a...>
Date: Thu, 14 Dec 2017 22:08:07 +0900 (JST)
Subject: [ruby-changes:49121] eregon:r61237 (trunk): The main Thread should have report_on_exception=true for consistency

eregon	2017-12-14 22:08:02 +0900 (Thu, 14 Dec 2017)

  New Revision: 61237

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61237

  Log:
    The main Thread should have report_on_exception=true for consistency
    
    * Adapt test and add specs.
    * See [Feature #14143] [ruby-core:84227]

  Modified files:
    trunk/spec/ruby/core/thread/report_on_exception_spec.rb
    trunk/test/ruby/test_thread.rb
    trunk/thread.c
    trunk/vm.c
Index: thread.c
===================================================================
--- thread.c	(revision 61236)
+++ thread.c	(revision 61237)
@@ -743,7 +743,6 @@ thread_create_core(VALUE thval, VALUE ar https://github.com/ruby/ruby/blob/trunk/thread.c#L743
     RBASIC_CLEAR_CLASS(th->pending_interrupt_mask_stack);
 
     native_mutex_initialize(&th->interrupt_lock);
-    th->report_on_exception = th->vm->thread_report_on_exception;
 
     /* kick thread */
     err = native_thread_create(th);
Index: spec/ruby/core/thread/report_on_exception_spec.rb
===================================================================
--- spec/ruby/core/thread/report_on_exception_spec.rb	(revision 61236)
+++ spec/ruby/core/thread/report_on_exception_spec.rb	(revision 61237)
@@ -34,6 +34,16 @@ ruby_version_is "2.4" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/thread/report_on_exception_spec.rb#L34
   end
 
   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
       t = Thread.new { Thread.current.report_on_exception = true }
       t.join
Index: vm.c
===================================================================
--- vm.c	(revision 61236)
+++ vm.c	(revision 61237)
@@ -2518,6 +2518,7 @@ th_init(rb_thread_t *th, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L2518
     th->retval = Qundef;
 #endif
     th->name = Qnil;
+    th->report_on_exception = th->vm->thread_report_on_exception;
 }
 
 static VALUE
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 61236)
+++ test/ruby/test_thread.rb	(revision 61237)
@@ -382,8 +382,8 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L382
 
       assert_equal(true, Thread.report_on_exception,
                    "global flag is true by default")
-      assert_equal(false, Thread.current.report_on_exception,
-                   "the main thread has report_on_exception=false")
+      assert_equal(true, Thread.current.report_on_exception,
+                   "the main thread has report_on_exception=true")
 
       Thread.report_on_exception = true
       Thread.current.report_on_exception = false

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]