summaryrefslogtreecommitdiff
path: root/test/test_timeout.rb
AgeCommit message (Collapse)Author
2025-12-26[ruby/timeout] add test case for string argumentt-mangoe
https://github.com/ruby/timeout/commit/fef9d07f44
2025-12-12[ruby/timeout] Restore original signal handler in test_timeout_in_trap_handlerBenoit Daloze
https://github.com/ruby/timeout/commit/4ae8631acf
2025-12-11[ruby/timeout] Fix failing timeout testLuke Gruber
``` Run options: "--ruby=./miniruby -I../ruby/lib -I. -I.ext/common ../ruby/tool/runruby.rb --extout=.ext -- --disable-gems" --excludes-dir=../ruby/test/.excludes --name=!/memory_leak/ --seed=9843 [ 1/31] TestTimeout#test_timeout_in_trap_handler = 0.00 s 1) Error: TestTimeout#test_timeout_in_trap_handler: NoMethodError: undefined method 'kill' for nil /Users/luke/workspace/ruby-dev/ruby/test/test_timeout.rb:9:in 'TestTimeout#kill_timeout_thread' /Users/luke/workspace/ruby-dev/ruby/test/test_timeout.rb:424:in 'TestTimeout#test_timeout_in_trap_handler' Finished tests in 2.715032s, 11.4179 tests/s, 52.3014 assertions/s. 31 tests, 142 assertions, 0 failures, 1 errors, 0 skips ruby -v: ruby 4.0.0dev (2025-12-11T21:56:23Z fix_timeout_test https://github.com/ruby/timeout/commit/1c5eacbf9a) +PRISM [arm64-darwin24] make: *** [yes-test-all] Error 1 ``` https://github.com/ruby/timeout/commit/e5bc1de901
2025-12-11[ruby/timeout] Add windows to CI matrixJean Boussier
https://github.com/ruby/timeout/commit/c8d63ce3fe
2025-12-11[ruby/timeout] Skip signal test on windowsJean Boussier
Windows has no SIGUSR1. There might be another usable signal, but this is breaking ruby master so I just want a quick fix for now. https://github.com/ruby/timeout/commit/b19043e8d0
2025-12-11[ruby/timeout] Make Timeout.timeout work in a trap handler on CRubyBenoit Daloze
* Fixes https://github.com/ruby/timeout/issues/17 https://github.com/ruby/timeout/commit/1a499a8f96
2025-12-11[ruby/timeout] Reset the interrupt mask when creating the Timeout threadBenoit Daloze
* Add tests related to Thread.handle_interrupt * Fixes https://github.com/ruby/timeout/issues/41 https://github.com/ruby/timeout/commit/a52720e82a
2025-12-08[ruby/timeout] Revert "Exclude constantly-failing test on x86_64-darwin"Koichi Sasada
This reverts commit https://github.com/ruby/timeout/commit/45816b1b2602. https://github.com/ruby/timeout/commit/b54f91e9dd
2025-12-06[ruby/timeout] Test that Timeout does not expose extra constantsBenoit Daloze
https://github.com/ruby/timeout/commit/4de4b4759c
2025-12-05[ruby/timeout] Exclude constantly-failing test on x86_64-darwinBenoit Daloze
* https://github.com/ruby/ruby-dev-builder/actions/runs/19973218359/job/57293388626 https://github.com/ruby/timeout/commit/45816b1b26
2025-12-05[ruby/timeout] Fix condition and fix test to catch that broken conditionBenoit Daloze
https://github.com/ruby/timeout/commit/82fb6f6925
2025-12-05[ruby/timeout] support RactorKoichi Sasada
1. Introduce State to store all status. 2. Store State instance to the Ractor local storage if possible 3. Make `GET_TIME` (Method object) shareable if possible 3 is supporeted Ruby 4.0 and later, so the Rator support is works only on Ruby 4.0 and later. https://github.com/ruby/timeout/commit/54ff671c6c
2025-12-05[ruby/timeout] Only the timeout method should be public on the Timeout moduleBenoit Daloze
https://github.com/ruby/timeout/commit/cd51eac3ca
2025-11-26[ruby/timeout] Revert "Suppress warnings in two tests"Nobuyoshi Nakada
This reverts commit https://github.com/ruby/timeout/commit/983cbf636a17, that is fixed by test-unit 3.7.3. https://github.com/ruby/timeout/commit/095207f270
2025-11-10[ruby/timeout] Suppress warnings in two testsOlle Jonsson
Failed build in #70. Pre-3.0 versions of Ruby didn't support pattern matching, and power_assert warned. https://github.com/ruby/timeout/commit/983cbf636a
2025-03-05Revert "try to show timeout sec"Koichi Sasada
This reverts commit ce66eea167847d4300150791bde4932b907b0cc0. Notes: Merged: https://github.com/ruby/ruby/pull/12851
2025-03-04try to show timeout secKoichi Sasada
http://ci.rvm.jp/results/trunk-gc-asserts@ruby-sp2-noble-docker/5632508 ``` 1) Error: TestEval#test_outer_local_variable_under_gc_compact_stress: Test::Unit::ProxyError: execution of Test::Unit::CoreAssertions#assert_separately expired timeout (10 sec) pid 1339179 killed by SIGABRT (signal 6) (core dumped) ``` seems that timeout scale doesn't work even though `RUBY_TEST_TIMEOUT_SCALE` is specified. This patch tries to print the timeout with scale information. Notes: Merged: https://github.com/ruby/ruby/pull/12849
2024-12-03[ruby/timeout] updated testsCosmicOppai
https://github.com/ruby/timeout/commit/c6d121aa18
2024-12-03[ruby/timeout] refactor the change to raise for nil and type-errror and ↵CosmicOppai
added tests https://github.com/ruby/timeout/commit/ffc8d7c003
2024-12-03[ruby/timeout] refactor the change to keep the compatability with nil and ↵CosmicOppai
type-errror and added tests https://github.com/ruby/timeout/commit/e8a7dbdb87
2024-12-03[ruby/timeout] refactor the change to keep the compatability with nil and ↵CosmicOppai
type-errror and added tests https://github.com/ruby/timeout/commit/8342544979
2024-05-28Make test_nested_timeouts less flakyYusuke Endoh
This test randomly fails due to the bug reported in [Bug #20314], where the two timeouts are too close so that they can expire at the same time. As a workaround, this change increases the time difference between timeouts. This will reduce the probability of simultaneous expirations and lower flakiness.
2023-11-08Prevent a warning: assigned but unused variable - raised_exceptionYusuke Endoh
2023-11-07[ruby/timeout] tests for blank secondsJohn Bachir
https://github.com/ruby/timeout/commit/54bc7639d2
2023-11-07[ruby/timeout] nested exception tests for discussionJohn Bachir
https://github.com/ruby/timeout/commit/3e42aa4d84
2023-07-03[ruby/timeout] Test that work is done in the same thread/fiber asJohn Bachir
the caller (https://github.com/ruby/timeout/pull/34) * see discussion in https://github.com/ruby/timeout/pull/30#issuecomment-1616179651
2023-06-22[ruby/timeout] Raise exception instead of throw/catch for timeoutsJeremy Evans
(https://github.com/ruby/timeout/pull/30) throw/catch is used for non-local control flow, not for exceptional situations. For exceptional situations, raise should be used instead. A timeout is an exceptional situation, so it should use raise, not throw/catch. Timeout's implementation that uses throw/catch internally causes serious problems. Consider the following code: ```ruby def handle_exceptions yield rescue Exception => exc handle_error # e.g. ROLLBACK for databases raise ensure handle_exit unless exc # e.g. COMMIT for databases end Timeout.timeout(1) do handle_exceptions do do_something end end ``` This kind of design ensures that all exceptions are handled as errors, and ensures that all exits (normal exit, early return, throw/catch) are not handled as errors. With Timeout's throw/catch implementation, this type of code does not work, since a timeout triggers the normal exit path. See https://github.com/rails/rails/pull/29333 for an example of the damage Timeout's design has caused the Rails ecosystem. This switches Timeout.timeout to use raise/rescue internally. It adds a Timeout::ExitException subclass of exception for the internal raise/rescue, which Timeout.timeout will convert to Timeout::Error for backwards compatibility. Timeout::Error remains a subclass of RuntimeError. This is how timeout used to work in Ruby 2.0. It was changed in Ruby 2.1, after discussion in [Bug #8730] (commit https://github.com/ruby/timeout/commit/238c003c921e in the timeout repository). I think the change from using raise/rescue to using throw/catch has caused significant harm to the Ruby ecosystem at large, and reverting it is the most sensible choice. From the translation of [Bug #8730], it appears the issue was that someone could rescue Exception and not reraise the exception, causing timeout errors to be swallowed. However, such code is broken anyway. Using throw/catch causes far worse problems, because then it becomes impossible to differentiate between normal control flow and exceptional control flow. Also related to this is [Bug #11344], which changed how Thread.handle_interrupt interacted with Timeout. https://github.com/ruby/timeout/commit/f16545abe6 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-02-15[ruby/timeout] Simplify testBenoit Daloze
https://github.com/ruby/timeout/commit/db017da726
2023-02-15[ruby/timeout] Don't move the timer_thread when it's enclosedRick Blommers
Don't move the timer_thread to ThreadGroup::Default, when it's created in an enclosed ThreadGroup. Prevents the exception: "add" can't move from the enclosed thread group" https://github.com/ruby/timeout/commit/eb889d2c8b
2022-09-28[ruby/timeout] Explicit add the timeout thread to default ThreadGroupLars Kanis
Otherwise the timeout thread would be added to the ThreadGroup of the thread that makes the first call to Timeout.timeout . Fixes bug 19020: https://bugs.ruby-lang.org/issues/19020 Add a test case to make sure the common thread doesn't leak to another ThreadGroup https://github.com/ruby/timeout/commit/c4f1385c9a
2022-05-19[ruby/timeout] Handle Timeout + fork and add test for itBenoit Daloze
https://github.com/ruby/timeout/commit/4baee63b9b
2022-05-19[ruby/timeout] Reimplement Timeout.timeout with a single thread and a QueueBenoit Daloze
https://github.com/ruby/timeout/commit/2bafc458f1
2021-09-28[ruby/timeout] test that yield is given number of secondsJohn Bachir
https://github.com/ruby/timeout/commit/ec5a614334
2021-09-27[ruby/timeout] test for basic functionalityJohn Bachir
https://github.com/ruby/timeout/commit/1c6bb90aea
2021-05-06[ruby/timeout] Make Timeout::Error#exception with multiple arguments not ↵Jeremy Evans
ignore arguments This makes: raise(Timeout::Error.new("hello"), "world") raise a TimeoutError instance with "world" as the message instead of "hello", for consistency with other Ruby exception classes. This required some internal changes to keep the tests passing. Fixes [Bug #17812] https://github.com/ruby/timeout/commit/952154dbf9
2017-10-08Remove unnecessary `require 'thread'`kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07Use our domain instead of other's domainkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07timeout.rb: custom error messagenobu
* lib/timeout.rb (Timeout#timeout): add custom error message argument. [Feature #11650] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-30Use qualified namesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-03test_timeout.rb: exact messagesnobu
* test/test_timeout.rb (test_rescue_exit, test_custom_exception): assert with exact messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-13use Timeout.timeoutnobu
* time: Object#timeout has been deprecated a long time ago, use Timeout.timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-10test_timeout.rb: add an assertionnobu
* test/test_timeout.rb (test_custom_exception): assert that the given exception will raise on timeout. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-10timeout.rb: removed and use Timeout::Errornobu
* lib/timeout.rb (ExitException): removed internal exception class and use Timeout::Error instead, as using throw/catch to isolate each timeouts now. [ruby-dev:49179] [Bug #11344] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-28test_thread.rb: move thread switch testnobu
* test/ruby/test_thread.rb (test_switch_while_busy_loop): move from test/test_timeout.rb. [Bug #1402] * test/test_timeout.rb (test_timeout): no longer related to [Bug #1402]. [Bug #8523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27* test/test_timeout.rb (test_timeout): inverted test condition.hsbt
[Bug #8523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-08lib/timeout.rb: fallback to Timeout::Errornobu
* lib/timeout.rb (Timeout::ExitException.catch): pass arguments for new instance. * lib/timeout.rb (Timeout::ExitException#exception): fallback to Timeout::Error if couldn't throw. [ruby-dev:47872] [Bug #9380] * lib/timeout.rb (Timeout#timeout): initialize ExitException with message for the fallback case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-07timeout.rb: fix for ExitExceptionnobu
* lib/timeout.rb (Timeout#timeout): should not rescue ordinarily raised ExitException, which should not be thrown. * lib/timeout.rb (Timeout::ExitException.catch): set @thread only if it ought to be caught. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-07timeout.rb: defer creating custom exceptionnobu
* lib/timeout.rb (Timeout#timeout): when a custom exception is given, no instance is needed to be caught, so defer creating new instance until it is raised. [ruby-core:59511] [Bug #9354] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-07test_timeout.rb: shorten waiting timesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e