| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | if ENV["HOMEBREW_TESTS_COVERAGE"] | 
					
						
							|  |  |  |   require "simplecov" | 
					
						
							| 
									
										
										
										
											2021-04-01 20:29:27 -04:00
										 |  |  |   require "simplecov-cobertura" | 
					
						
							| 
									
										
										
										
											2017-03-05 08:06:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-01 18:59:46 -04:00
										 |  |  |   formatters = [ | 
					
						
							|  |  |  |     SimpleCov::Formatter::HTMLFormatter, | 
					
						
							| 
									
										
										
										
											2021-04-01 21:19:56 -04:00
										 |  |  |     SimpleCov::Formatter::CoberturaFormatter, | 
					
						
							| 
									
										
										
										
											2021-04-01 18:59:46 -04:00
										 |  |  |   ] | 
					
						
							| 
									
										
										
										
											2021-02-04 12:35:55 -05:00
										 |  |  |   SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(formatters) | 
					
						
							| 
									
										
										
										
											2018-12-30 20:06:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-04 12:35:55 -05:00
										 |  |  |   if RUBY_PLATFORM[/darwin/] && ENV["TEST_ENV_NUMBER"] | 
					
						
							|  |  |  |     SimpleCov.at_exit do | 
					
						
							|  |  |  |       result = SimpleCov.result | 
					
						
							|  |  |  |       result.format! if ParallelTests.number_of_running_processes <= 1
 | 
					
						
							| 
									
										
										
										
											2019-01-09 18:59:12 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-03-05 08:06:45 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-14 11:56:32 -05:00
										 |  |  | require_relative "../warnings" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Warnings.ignore :parser_syntax do | 
					
						
							|  |  |  |   require "rubocop" | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | require "rspec/its" | 
					
						
							| 
									
										
										
										
											2020-12-22 18:03:01 +00:00
										 |  |  | require "rspec/github" | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | require "rspec/retry" | 
					
						
							| 
									
										
										
										
											2020-11-17 04:49:54 +01:00
										 |  |  | require "rspec/sorbet" | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | require "rubocop/rspec/support" | 
					
						
							|  |  |  | require "find" | 
					
						
							| 
									
										
										
										
											2020-05-18 16:28:43 +05:30
										 |  |  | require "byebug" | 
					
						
							| 
									
										
										
										
											2020-07-22 00:38:27 +02:00
										 |  |  | require "timeout" | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-30 04:37:09 +01:00
										 |  |  | $LOAD_PATH.push(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib")) | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-17 14:23:33 +02:00
										 |  |  | require_relative "../global" | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | require "test/support/no_seed_progress_formatter" | 
					
						
							| 
									
										
										
										
											2020-08-14 13:48:03 -04:00
										 |  |  | require "test/support/helper/cask" | 
					
						
							| 
									
										
										
										
											2017-02-21 04:52:53 +01:00
										 |  |  | require "test/support/helper/fixtures" | 
					
						
							| 
									
										
										
										
											2017-02-25 13:26:50 +01:00
										 |  |  | require "test/support/helper/formula" | 
					
						
							| 
									
										
										
										
											2017-02-28 14:50:46 +01:00
										 |  |  | require "test/support/helper/mktmpdir" | 
					
						
							| 
									
										
										
										
											2017-07-08 00:57:08 +02:00
										 |  |  | require "test/support/helper/output_as_tty" | 
					
						
							| 
									
										
										
										
											2017-03-05 06:31:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | require "test/support/helper/spec/shared_context/homebrew_cask" if OS.mac? | 
					
						
							| 
									
										
										
										
											2017-02-15 19:20:38 +01:00
										 |  |  | require "test/support/helper/spec/shared_context/integration_test" | 
					
						
							| 
									
										
										
										
											2020-12-02 20:47:53 -05:00
										 |  |  | require "test/support/helper/spec/shared_examples/formulae_exist" | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | TEST_DIRECTORIES = [ | 
					
						
							|  |  |  |   CoreTap.instance.path/"Formula", | 
					
						
							|  |  |  |   HOMEBREW_CACHE, | 
					
						
							|  |  |  |   HOMEBREW_CACHE_FORMULA, | 
					
						
							|  |  |  |   HOMEBREW_CELLAR, | 
					
						
							| 
									
										
										
										
											2018-09-06 18:38:43 +01:00
										 |  |  |   HOMEBREW_LOCKS, | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |   HOMEBREW_LOGS, | 
					
						
							|  |  |  |   HOMEBREW_TEMP, | 
					
						
							|  |  |  | ].freeze | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-17 04:49:54 +01:00
										 |  |  | # Make `instance_double` and `class_double` | 
					
						
							|  |  |  | # work when type-checking is active. | 
					
						
							|  |  |  | RSpec::Sorbet.allow_doubles! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | RSpec.configure do |config| | 
					
						
							|  |  |  |   config.order = :random | 
					
						
							| 
									
										
										
										
											2017-02-27 22:12:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 23:19:13 +02:00
										 |  |  |   config.raise_errors_for_deprecations! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-07 16:34:29 +01:00
										 |  |  |   config.filter_run_when_matching :focus | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-09 18:59:12 +00:00
										 |  |  |   config.silence_filter_announcements = true if ENV["TEST_ENV_NUMBER"] | 
					
						
							| 
									
										
										
										
											2018-06-06 18:17:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 22:13:00 +00:00
										 |  |  |   config.expect_with :rspec do |c| | 
					
						
							|  |  |  |     c.max_formatted_output_length = 200
 | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-05-24 14:28:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-29 12:43:47 +01:00
										 |  |  |   # Use rspec-retry to handle flaky tests. | 
					
						
							|  |  |  |   config.default_sleep_interval = 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # Don't make retries as noisy unless in CI. | 
					
						
							| 
									
										
										
										
											2020-06-29 09:54:06 +01:00
										 |  |  |   if ENV["CI"] | 
					
						
							|  |  |  |     config.verbose_retry = true | 
					
						
							|  |  |  |     config.display_try_failure_messages = true | 
					
						
							| 
									
										
										
										
											2021-06-29 12:43:47 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2020-11-29 16:08:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-29 12:43:47 +01:00
										 |  |  |   # Don't want the nicer default retry behaviour when using BuildPulse to | 
					
						
							|  |  |  |   # identify flaky tests. | 
					
						
							|  |  |  |   config.default_retry_count = 2 unless ENV["BUILDPULSE"] | 
					
						
							| 
									
										
										
										
											2020-06-29 09:54:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-29 12:43:47 +01:00
										 |  |  |   # Increase timeouts for integration tests (as we expect them to take longer). | 
					
						
							|  |  |  |   config.around(:each, :integration_test) do |example| | 
					
						
							|  |  |  |     example.metadata[:timeout] ||= 120
 | 
					
						
							|  |  |  |     example.run | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config.around(:each, :needs_network) do |example| | 
					
						
							|  |  |  |     example.metadata[:timeout] ||= 120
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Don't want the nicer default retry behaviour when using BuildPulse to | 
					
						
							|  |  |  |     # identify flaky tests. | 
					
						
							|  |  |  |     example.metadata[:retry] ||= 4 unless ENV["BUILDPULSE"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     example.metadata[:retry_wait] ||= 2
 | 
					
						
							|  |  |  |     example.metadata[:exponential_backoff] ||= true | 
					
						
							|  |  |  |     example.run | 
					
						
							| 
									
										
										
										
											2020-06-29 09:54:06 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-24 14:28:20 +01:00
										 |  |  |   # Never truncate output objects. | 
					
						
							|  |  |  |   RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = nil | 
					
						
							| 
									
										
										
										
											2018-05-24 14:28:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:43:14 +02:00
										 |  |  |   config.include(FileUtils) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |   config.include(RuboCop::RSpec::ExpectOffense) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-14 13:48:03 -04:00
										 |  |  |   config.include(Test::Helper::Cask) | 
					
						
							| 
									
										
										
										
											2017-02-21 04:52:53 +01:00
										 |  |  |   config.include(Test::Helper::Fixtures) | 
					
						
							| 
									
										
										
										
											2017-02-25 13:26:50 +01:00
										 |  |  |   config.include(Test::Helper::Formula) | 
					
						
							| 
									
										
										
										
											2017-02-28 14:50:46 +01:00
										 |  |  |   config.include(Test::Helper::MkTmpDir) | 
					
						
							| 
									
										
										
										
											2017-07-08 00:57:08 +02:00
										 |  |  |   config.include(Test::Helper::OutputAsTTY) | 
					
						
							| 
									
										
										
										
											2017-02-27 22:12:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-28 13:42:52 +01:00
										 |  |  |   config.before(:each, :needs_compat) do | 
					
						
							| 
									
										
										
										
											2020-09-08 19:23:32 +02:00
										 |  |  |     skip "Requires the compatibility layer." if ENV["HOMEBREW_NO_COMPAT"] | 
					
						
							| 
									
										
										
										
											2017-02-28 13:42:52 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-28 14:11:29 +01:00
										 |  |  |   config.before(:each, :needs_linux) do | 
					
						
							| 
									
										
										
										
											2020-09-08 19:23:32 +02:00
										 |  |  |     skip "Not running on Linux." unless OS.linux? | 
					
						
							| 
									
										
										
										
											2019-07-28 14:11:29 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-27 22:12:32 +01:00
										 |  |  |   config.before(:each, :needs_macos) do | 
					
						
							| 
									
										
										
										
											2020-09-08 19:23:32 +02:00
										 |  |  |     skip "Not running on macOS." unless OS.mac? | 
					
						
							| 
									
										
										
										
											2017-02-12 21:37:46 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2017-02-27 22:12:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-27 11:52:30 -08:00
										 |  |  |   config.before(:each, :needs_java) do | 
					
						
							| 
									
										
										
										
											2021-01-25 09:18:10 +00:00
										 |  |  |     skip "Java is not installed." unless which("java") | 
					
						
							| 
									
										
										
										
											2018-11-27 11:52:30 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-27 22:12:32 +01:00
										 |  |  |   config.before(:each, :needs_python) do | 
					
						
							| 
									
										
										
										
											2020-09-08 19:23:32 +02:00
										 |  |  |     skip "Python is not installed." unless which("python") | 
					
						
							| 
									
										
										
										
											2017-02-27 22:12:32 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 12:26:18 +01:00
										 |  |  |   config.before(:each, :needs_network) do | 
					
						
							|  |  |  |     skip "Requires network connection." unless ENV["HOMEBREW_TEST_ONLINE"] | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-05 18:36:26 -08:00
										 |  |  |   config.before(:each, :needs_svn) do | 
					
						
							| 
									
										
										
										
											2021-10-03 21:47:17 +01:00
										 |  |  |     svn_shim = HOMEBREW_SHIMS_PATH/"shared/svn" | 
					
						
							| 
									
										
										
										
											2020-09-11 11:11:42 +01:00
										 |  |  |     skip "Subversion is not installed." unless quiet_system svn_shim, "--version" | 
					
						
							| 
									
										
										
										
											2020-06-24 10:13:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-11 11:11:42 +01:00
										 |  |  |     svn_shim_path = Pathname(Utils.popen_read(svn_shim, "--homebrew=print-path").chomp.presence) | 
					
						
							| 
									
										
										
										
											2022-06-15 05:40:43 +01:00
										 |  |  |     svn_paths = PATH.new(ENV.fetch("PATH")) | 
					
						
							| 
									
										
										
										
											2020-09-11 11:11:42 +01:00
										 |  |  |     svn_paths.prepend(svn_shim_path.dirname) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-06 14:58:33 +00:00
										 |  |  |     if OS.mac? | 
					
						
							|  |  |  |       xcrun_svn = Utils.popen_read("xcrun", "-f", "svn") | 
					
						
							|  |  |  |       svn_paths.append(File.dirname(xcrun_svn)) if $CHILD_STATUS.success? && xcrun_svn.present? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     svn = which("svn", svn_paths) | 
					
						
							| 
									
										
										
										
											2020-09-11 11:11:42 +01:00
										 |  |  |     skip "svn is not installed." unless svn | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-06 14:58:33 +00:00
										 |  |  |     svnadmin = which("svnadmin", svn_paths) | 
					
						
							| 
									
										
										
										
											2020-09-11 11:11:42 +01:00
										 |  |  |     skip "svnadmin is not installed." unless svnadmin | 
					
						
							| 
									
										
										
										
											2019-11-06 14:58:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-15 05:40:43 +01:00
										 |  |  |     ENV["PATH"] = PATH.new(ENV.fetch("PATH")) | 
					
						
							| 
									
										
										
										
											2019-11-06 14:58:33 +00:00
										 |  |  |                       .append(svn.dirname) | 
					
						
							|  |  |  |                       .append(svnadmin.dirname) | 
					
						
							| 
									
										
										
										
											2018-08-13 10:04:32 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-31 17:07:53 +00:00
										 |  |  |   config.before(:each, :needs_homebrew_curl) do | 
					
						
							| 
									
										
										
										
											2022-05-30 04:25:24 +01:00
										 |  |  |     ENV["HOMEBREW_CURL"] = HOMEBREW_BREWED_CURL_PATH | 
					
						
							| 
									
										
										
										
											2021-12-31 17:07:53 +00:00
										 |  |  |     skip "A `curl` with TLS 1.3 support is required." unless curl_supports_tls13? | 
					
						
							| 
									
										
										
										
											2021-10-23 15:09:34 -04:00
										 |  |  |   rescue FormulaUnavailableError | 
					
						
							|  |  |  |     skip "No `curl` formula is available." | 
					
						
							| 
									
										
										
										
											2021-09-24 22:44:27 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 10:04:32 -07:00
										 |  |  |   config.before(:each, :needs_unzip) do | 
					
						
							| 
									
										
										
										
											2020-09-11 11:11:42 +01:00
										 |  |  |     skip "Unzip is not installed." unless which("unzip") | 
					
						
							| 
									
										
										
										
											2018-02-05 18:36:26 -08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 13:39:11 +00:00
										 |  |  |   config.around do |example| | 
					
						
							| 
									
										
										
										
											2017-06-24 07:01:35 +02:00
										 |  |  |     def find_files | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |       return [] unless File.exist?(TEST_TMPDIR) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-24 07:01:35 +02:00
										 |  |  |       Find.find(TEST_TMPDIR) | 
					
						
							|  |  |  |           .reject { |f| File.basename(f) == ".DS_Store" } | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |           .reject { |f| TEST_DIRECTORIES.include?(Pathname(f)) } | 
					
						
							| 
									
										
										
										
											2017-06-24 07:01:35 +02:00
										 |  |  |           .map { |f| f.sub(TEST_TMPDIR, "") } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     Homebrew.raise_deprecation_exceptions = true | 
					
						
							| 
									
										
										
										
											2019-11-05 21:53:41 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     Formulary.clear_cache | 
					
						
							|  |  |  |     Tap.clear_cache | 
					
						
							|  |  |  |     DependencyCollector.clear_cache | 
					
						
							|  |  |  |     Formula.clear_cache | 
					
						
							|  |  |  |     Keg.clear_cache | 
					
						
							|  |  |  |     Tab.clear_cache | 
					
						
							| 
									
										
										
										
											2021-03-19 03:21:27 +00:00
										 |  |  |     Dependency.clear_cache | 
					
						
							|  |  |  |     Requirement.clear_cache | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     FormulaInstaller.clear_attempted | 
					
						
							|  |  |  |     FormulaInstaller.clear_installed | 
					
						
							| 
									
										
										
										
											2021-10-31 10:52:40 -07:00
										 |  |  |     FormulaInstaller.clear_fetched | 
					
						
							| 
									
										
										
										
											2022-05-30 04:10:25 +01:00
										 |  |  |     Utils::Curl.clear_path_cache | 
					
						
							| 
									
										
										
										
											2018-07-16 10:55:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     TEST_DIRECTORIES.each(&:mkpath) | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     @__homebrew_failed = Homebrew.failed? | 
					
						
							| 
									
										
										
										
											2017-02-18 16:52:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     @__files_before_test = find_files | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     @__env = ENV.to_hash # dup doesn't work on ENV | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     @__stdout = $stdout.clone | 
					
						
							|  |  |  |     @__stderr = $stderr.clone | 
					
						
							| 
									
										
										
										
											2022-03-06 19:06:28 +00:00
										 |  |  |     @__stdin = $stdin.clone | 
					
						
							| 
									
										
										
										
											2020-04-07 08:32:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |     begin | 
					
						
							| 
									
										
										
										
											2021-01-27 15:04:13 +00:00
										 |  |  |       if (example.metadata.keys & [:focus, :byebug]).empty? && !ENV.key?("HOMEBREW_VERBOSE_TESTS") | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |         $stdout.reopen(File::NULL) | 
					
						
							|  |  |  |         $stderr.reopen(File::NULL) | 
					
						
							| 
									
										
										
										
											2022-10-20 11:28:27 +01:00
										 |  |  |       else | 
					
						
							|  |  |  |         # don't retry when focusing/debugging | 
					
						
							|  |  |  |         config.default_retry_count = 0
 | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2022-03-06 19:06:28 +00:00
										 |  |  |       $stdin.reopen(File::NULL) | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-22 00:38:27 +02:00
										 |  |  |       begin | 
					
						
							| 
									
										
										
										
											2020-10-29 09:50:17 +00:00
										 |  |  |         timeout = example.metadata.fetch(:timeout, 60) | 
					
						
							| 
									
										
										
										
											2020-07-22 00:38:27 +02:00
										 |  |  |         Timeout.timeout(timeout) do | 
					
						
							|  |  |  |           example.run | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2020-10-29 09:50:17 +00:00
										 |  |  |       rescue Timeout::Error => e | 
					
						
							|  |  |  |         example.example.set_exception(e) | 
					
						
							| 
									
										
										
										
											2020-07-22 00:38:27 +02:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2020-04-07 08:32:30 +02:00
										 |  |  |     rescue SystemExit => e | 
					
						
							| 
									
										
										
										
											2020-10-29 09:50:17 +00:00
										 |  |  |       example.example.set_exception(e) | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |     ensure | 
					
						
							|  |  |  |       ENV.replace(@__env) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-07 08:32:30 +02:00
										 |  |  |       $stdout.reopen(@__stdout) | 
					
						
							|  |  |  |       $stderr.reopen(@__stderr) | 
					
						
							| 
									
										
										
										
											2022-03-06 19:06:28 +00:00
										 |  |  |       $stdin.reopen(@__stdin) | 
					
						
							| 
									
										
										
										
											2020-04-07 08:32:30 +02:00
										 |  |  |       @__stdout.close | 
					
						
							|  |  |  |       @__stderr.close | 
					
						
							| 
									
										
										
										
											2022-03-06 19:06:28 +00:00
										 |  |  |       @__stdin.close | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 21:53:41 +00:00
										 |  |  |       Formulary.clear_cache | 
					
						
							|  |  |  |       Tap.clear_cache | 
					
						
							|  |  |  |       DependencyCollector.clear_cache | 
					
						
							| 
									
										
										
										
											2019-11-05 20:34:06 +00:00
										 |  |  |       Formula.clear_cache | 
					
						
							| 
									
										
										
										
											2019-11-05 20:33:32 +00:00
										 |  |  |       Keg.clear_cache | 
					
						
							| 
									
										
										
										
											2019-11-05 21:53:41 +00:00
										 |  |  |       Tab.clear_cache | 
					
						
							| 
									
										
										
										
											2021-03-19 03:21:27 +00:00
										 |  |  |       Dependency.clear_cache | 
					
						
							|  |  |  |       Requirement.clear_cache | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       FileUtils.rm_rf [ | 
					
						
							| 
									
										
										
										
											2020-12-17 18:09:33 +01:00
										 |  |  |         *TEST_DIRECTORIES, | 
					
						
							| 
									
										
										
										
											2018-09-25 22:03:29 +01:00
										 |  |  |         *Keg::MUST_EXIST_SUBDIRECTORIES, | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |         HOMEBREW_LINKED_KEGS, | 
					
						
							|  |  |  |         HOMEBREW_PINNED_KEGS, | 
					
						
							| 
									
										
										
										
											2018-09-25 22:03:29 +01:00
										 |  |  |         HOMEBREW_PREFIX/"var", | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |         HOMEBREW_PREFIX/"Caskroom", | 
					
						
							| 
									
										
										
										
											2019-10-21 12:27:39 -07:00
										 |  |  |         HOMEBREW_PREFIX/"Frameworks", | 
					
						
							| 
									
										
										
										
											2018-05-25 17:28:43 +02:00
										 |  |  |         HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-cask", | 
					
						
							| 
									
										
										
										
											2017-04-23 18:56:22 +01:00
										 |  |  |         HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bar", | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |         HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-bundle", | 
					
						
							|  |  |  |         HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-foo", | 
					
						
							|  |  |  |         HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-services", | 
					
						
							|  |  |  |         HOMEBREW_LIBRARY/"Taps/homebrew/homebrew-shallow", | 
					
						
							| 
									
										
										
										
											2018-04-13 16:40:08 +02:00
										 |  |  |         HOMEBREW_LIBRARY/"PinnedTaps", | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |         HOMEBREW_REPOSITORY/".git", | 
					
						
							|  |  |  |         CoreTap.instance.path/".git", | 
					
						
							|  |  |  |         CoreTap.instance.alias_dir, | 
					
						
							|  |  |  |         CoreTap.instance.path/"formula_renames.json", | 
					
						
							| 
									
										
										
										
											2020-11-30 12:29:07 -05:00
										 |  |  |         CoreTap.instance.path/"tap_migrations.json", | 
					
						
							|  |  |  |         CoreTap.instance.path/"audit_exceptions", | 
					
						
							|  |  |  |         CoreTap.instance.path/"style_exceptions", | 
					
						
							|  |  |  |         CoreTap.instance.path/"pypi_formula_mappings.json", | 
					
						
							| 
									
										
										
										
											2019-03-27 09:45:48 +00:00
										 |  |  |         *Pathname.glob("#{HOMEBREW_CELLAR}/*/"), | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |       ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-24 07:01:35 +02:00
										 |  |  |       files_after_test = find_files | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-18 02:30:47 +01:00
										 |  |  |       diff = Set.new(@__files_before_test) ^ Set.new(files_after_test) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |       expect(diff).to be_empty, <<~EOS | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |         file leak detected: | 
					
						
							|  |  |  |         #{diff.map { |f| "  #{f}" }.join("\n")} | 
					
						
							|  |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2017-02-18 16:52:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       Homebrew.failed = @__homebrew_failed | 
					
						
							| 
									
										
										
										
											2017-02-10 21:41:15 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2017-02-18 16:52:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-08 15:49:37 +01:00
										 |  |  | RSpec::Matchers.define_negated_matcher :not_to_output, :output | 
					
						
							| 
									
										
										
										
											2022-05-31 03:29:42 +01:00
										 |  |  | RSpec::Matchers.define_negated_matcher :not_raise_error, :raise_error | 
					
						
							| 
									
										
										
										
											2017-02-18 16:52:36 +01:00
										 |  |  | RSpec::Matchers.alias_matcher :have_failed, :be_failed | 
					
						
							| 
									
										
										
										
											2018-07-05 09:31:29 +02:00
										 |  |  | RSpec::Matchers.alias_matcher :a_string_containing, :include | 
					
						
							| 
									
										
										
										
											2018-09-17 20:49:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | RSpec::Matchers.define :a_json_string do | 
					
						
							|  |  |  |   match do |actual| | 
					
						
							| 
									
										
										
										
											2019-10-13 10:03:26 +01:00
										 |  |  |     JSON.parse(actual) | 
					
						
							|  |  |  |     true | 
					
						
							|  |  |  |   rescue JSON::ParserError | 
					
						
							|  |  |  |     false | 
					
						
							| 
									
										
										
										
											2018-09-17 20:49:43 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2020-09-05 07:41:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Match consecutive elements in an array. | 
					
						
							|  |  |  | RSpec::Matchers.define :array_including_cons do |*cons| | 
					
						
							|  |  |  |   match do |actual| | 
					
						
							|  |  |  |     expect(actual.each_cons(cons.size)).to include(cons) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |