Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add TEST_CASE_TIMEOUT #2765

Merged
merged 1 commit into from Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -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!
Expand Down
7 changes: 5 additions & 2 deletions test/helper.rb
Expand Up @@ -23,6 +23,9 @@

$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"
Expand Down Expand Up @@ -77,14 +80,14 @@ def run
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
Expand Down