Skip to content

Commit

Permalink
Add HOMEBREW_TEST_TIMEOUT_SECS env config
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.

Resolves https://github.com/orgs/Homebrew/discussions/5692.
  • Loading branch information
ZhongRuoyu committed Oct 24, 2024
1 parent be76abc commit 433a667
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ module EnvConfig
default_text: "macOS: `/private/tmp`, Linux: `/tmp`.",
default: HOMEBREW_DEFAULT_TEMP,
},
HOMEBREW_TEST_TIMEOUT_SECS: {
description: "If set, use this value in seconds as the timeout for formula test runs.",
default: 600,
},
HOMEBREW_UPDATE_TO_TAG: {
description: "If set, always use the latest stable tag (even if developer commands " \
"have been run).",
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Library/Homebrew/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
require "dev-cmd/test"
require "json/add/exception"

TEST_TIMEOUT_SECONDS = 5 * 60

begin
ENV.delete("HOMEBREW_FORBID_PACKAGES_FROM_PATHS")
args = Homebrew::DevCmd::Test.new.args
Expand Down Expand Up @@ -49,7 +47,7 @@
if args.debug? # --debug is interactive
run_test.call
else
Timeout.timeout(TEST_TIMEOUT_SECONDS, &run_test)
Timeout.timeout(Homebrew::EnvConfig.test_timeout_secs, &run_test)
end
rescue Exception => e # rubocop:disable Lint/RescueException
error_pipe.puts e.to_json
Expand Down

0 comments on commit 433a667

Please sign in to comment.