From 433a667e5c80bf20da2db56afcdb539f46762247 Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Fri, 25 Oct 2024 02:39:41 +0800 Subject: [PATCH] Add `HOMEBREW_TEST_TIMEOUT_SECS` env config 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. --- Library/Homebrew/env_config.rb | 4 ++++ Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi | 3 +++ Library/Homebrew/test.rb | 4 +--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index a3b3124e36f0f..63f97e7df17f1 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -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).", diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi index d8e7fbb8b290b..0e54bd3ee21fd 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi @@ -280,6 +280,9 @@ module Homebrew::EnvConfig sig { returns(String) } def temp; end + sig { returns(Integer) } + def test_timeout_secs; end + sig { returns(T::Boolean) } def update_to_tag?; end diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index 7a333b3606bbb..83fa39c7a6af5 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -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 @@ -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