Skip to content

Commit

Permalink
Add HOMEBREW_TEST_TIMEOUT_SECS env var
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ZhongRuoyu and carlocab committed Oct 26, 2024
1 parent bbe5a85 commit d2cdd99
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Library/Homebrew/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
require "dev-cmd/test"
require "json/add/exception"

TEST_TIMEOUT_SECONDS = 5 * 60
DEFAULT_TEST_TIMEOUT_SECONDS = 5 * 60

begin
ENV.delete("HOMEBREW_FORBID_PACKAGES_FROM_PATHS")
Expand Down Expand Up @@ -49,7 +49,9 @@
if args.debug? # --debug is interactive
run_test.call
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
rescue Exception => e # rubocop:disable Lint/RescueException
error_pipe.puts e.to_json
Expand Down

0 comments on commit d2cdd99

Please sign in to comment.