From 7d0166023b5148e75c0f9a823f6a7e6b926484fb Mon Sep 17 00:00:00 2001 From: John Bachir Date: Sat, 1 Jul 2023 22:21:11 -0400 Subject: [PATCH 1/5] test that work is done in the same thread as the caller see discussion in https://github.com/ruby/timeout/pull/30#issuecomment-1616179651 --- test/test_timeout.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 236883a..aa06461 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -4,6 +4,10 @@ class TestTimeout < Test::Unit::TestCase + def test_work_is_done_in_same_thread_as_caller + assert_equal Thread.current, Timeout.timeout(10){Thread.current} + end + def test_non_timing_out_code_is_successful assert_nothing_raised do assert_equal :ok, Timeout.timeout(1){ :ok } From 1773c17878b3fc426d2df1f5f59e57ca6ef0396c Mon Sep 17 00:00:00 2001 From: John Bachir Date: Sat, 1 Jul 2023 22:25:26 -0400 Subject: [PATCH 2/5] Update test_timeout.rb --- test/test_timeout.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_timeout.rb b/test/test_timeout.rb index aa06461..48cc6ff 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -5,7 +5,7 @@ class TestTimeout < Test::Unit::TestCase def test_work_is_done_in_same_thread_as_caller - assert_equal Thread.current, Timeout.timeout(10){Thread.current} + assert_equal Thread.current, Timeout.timeout(10){ Thread.current } end def test_non_timing_out_code_is_successful From e5979361ebe99de7843635accb549e6ae34dbcac Mon Sep 17 00:00:00 2001 From: John Bachir Date: Sat, 1 Jul 2023 22:27:47 -0400 Subject: [PATCH 3/5] Update test_timeout.rb --- test/test_timeout.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 48cc6ff..d0a2d9e 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -8,6 +8,10 @@ def test_work_is_done_in_same_thread_as_caller assert_equal Thread.current, Timeout.timeout(10){ Thread.current } end + def test_work_is_done_in_same_fiber_as_caller + assert_equal Fiber.current, Timeout.timeout(10){ Fiber.current } + end + def test_non_timing_out_code_is_successful assert_nothing_raised do assert_equal :ok, Timeout.timeout(1){ :ok } From 516bcb16ac82efacab487b67a9494e1448a75d70 Mon Sep 17 00:00:00 2001 From: John Bachir Date: Sun, 2 Jul 2023 09:56:21 -0400 Subject: [PATCH 4/5] Update test_timeout.rb --- test/test_timeout.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_timeout.rb b/test/test_timeout.rb index d0a2d9e..f15467d 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -9,6 +9,7 @@ def test_work_is_done_in_same_thread_as_caller end def test_work_is_done_in_same_fiber_as_caller + require 'fiber' # needed for 3.0 and lower assert_equal Fiber.current, Timeout.timeout(10){ Fiber.current } end From ec07d5a7347f81e3022ed7e41773c4e10afaa0d4 Mon Sep 17 00:00:00 2001 From: John Bachir Date: Sun, 2 Jul 2023 16:18:29 -0400 Subject: [PATCH 5/5] Update test_timeout.rb --- test/test_timeout.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_timeout.rb b/test/test_timeout.rb index f15467d..0a8dc45 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -9,7 +9,7 @@ def test_work_is_done_in_same_thread_as_caller end def test_work_is_done_in_same_fiber_as_caller - require 'fiber' # needed for 3.0 and lower + require 'fiber' # needed for ruby 3.0 and lower assert_equal Fiber.current, Timeout.timeout(10){ Fiber.current } end