mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
tests: add TEST_CASE_TIMEOUT
(#2765)
Useful if you want quicker feedback when you know something fails instantly, example: rerun -x -c -- TEST_CASE_TIMEOUT=2 bundle e m test/test_integration_ssl.rb:126
This commit is contained in:
parent
1008c36a4a
commit
34871daef0
2 changed files with 10 additions and 2 deletions
|
@ -107,6 +107,11 @@ To run a single test:
|
|||
bundle exec m test/test_binder.rb:37
|
||||
```
|
||||
|
||||
To run a single test with 5 seconds as the test case timeout:
|
||||
```sh
|
||||
TEST_CASE_TIMEOUT=5 bundle exec m test/test_binder.rb:37
|
||||
```
|
||||
|
||||
## How to contribute
|
||||
|
||||
Puma could use your help in several areas!
|
||||
|
|
|
@ -23,6 +23,9 @@ Thread.abort_on_exception = true
|
|||
|
||||
$debugging_info = ''.dup
|
||||
$debugging_hold = false # needed for TestCLI#test_control_clustered
|
||||
$test_case_timeout = ENV.fetch("TEST_CASE_TIMEOUT") do
|
||||
RUBY_ENGINE == "ruby" ? 45 : 60
|
||||
end.to_i
|
||||
|
||||
require "puma"
|
||||
require "puma/detect"
|
||||
|
@ -77,14 +80,14 @@ module TimeoutEveryTestCase
|
|||
with_info_handler do
|
||||
time_it do
|
||||
capture_exceptions do
|
||||
::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 45 : 60, TestTookTooLong) do
|
||||
::Timeout.timeout($test_case_timeout, TestTookTooLong) do
|
||||
before_setup; setup; after_setup
|
||||
self.send self.name
|
||||
end
|
||||
end
|
||||
|
||||
capture_exceptions do
|
||||
::Timeout.timeout(RUBY_ENGINE == 'ruby' ? 45 : 60, TestTookTooLong) do
|
||||
::Timeout.timeout($test_case_timeout, TestTookTooLong) do
|
||||
Minitest::Test::TEARDOWN_METHODS.each { |hook| self.send hook }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue