Add HOMEBREW_TEST_TIMEOUT_SECS env var

Intended mainly for third-party formulae, this allows formula tests to
be run with a customised timeout.

This is a private, undocumented API and subject to change.

Co-authored-by: Carlo Cabrera <github@carlo.cab>
This commit is contained in:
Ruoyu Zhong 2024-10-25 02:39:41 +08:00
parent bbe5a858d5
commit d2cdd99591
No known key found for this signature in database

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