Merge pull request #18629 from Homebrew/env-config-test-timeout

Add `HOMEBREW_TEST_TIMEOUT_SECS` env var
This commit is contained in:
Ruoyu Zhong 2024-10-26 17:42:26 +08:00 committed by GitHub
commit 59d56f84ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,7 +16,7 @@ require "cli/parser"
require "dev-cmd/test" require "dev-cmd/test"
require "json/add/exception" require "json/add/exception"
TEST_TIMEOUT_SECONDS = 5 * 60 DEFAULT_TEST_TIMEOUT_SECONDS = 5 * 60
begin begin
ENV.delete("HOMEBREW_FORBID_PACKAGES_FROM_PATHS") ENV.delete("HOMEBREW_FORBID_PACKAGES_FROM_PATHS")
@ -49,7 +49,9 @@ begin
if args.debug? # --debug is interactive if args.debug? # --debug is interactive
run_test.call run_test.call
else else
Timeout.timeout(TEST_TIMEOUT_SECONDS, &run_test) # HOMEBREW_TEST_TIMEOUT_SECS is private API and subject to change.
timeout = ENV["HOMEBREW_TEST_TIMEOUT_SECS"]&.to_i || DEFAULT_TEST_TIMEOUT_SECONDS
Timeout.timeout(timeout, &run_test)
end end
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
error_pipe.puts e.to_json error_pipe.puts e.to_json