diff --git a/Library/.rubocop_rspec.yml b/Library/.rubocop_rspec.yml index 6b72706d06..5a47d33451 100644 --- a/Library/.rubocop_rspec.yml +++ b/Library/.rubocop_rspec.yml @@ -35,3 +35,7 @@ RSpec/NestedGroups: Max: 5 RSpec/MultipleMemoizedHelpers: Max: 12 + +# Annoying to have these autoremoved. +RSpec/Focus: + AutoCorrect: false diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index ef58dd8bd7..6725bd3f48 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -48,7 +48,6 @@ module Homebrew ENV.delete("HOMEBREW_NO_COLOR") ENV.delete("HOMEBREW_VERBOSE") ENV.delete("HOMEBREW_DEBUG") - ENV.delete("VERBOSE") ENV.delete("HOMEBREW_CASK_OPTS") ENV.delete("HOMEBREW_TEMP") ENV.delete("HOMEBREW_NO_GITHUB_API") @@ -68,6 +67,9 @@ module Homebrew # to use GPG to sign by default ENV["HOME"] = "#{HOMEBREW_LIBRARY_PATH}/test" + # Print verbose output when requesting debug or verbose output. + ENV["HOMEBREW_VERBOSE_TESTS"] = "1" if args.debug? || args.verbose? + if args.coverage? ENV["HOMEBREW_TESTS_COVERAGE"] = "1" FileUtils.rm_f "test/coverage/.resultset.json" diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb index f8c363ad44..bdff8c4f7a 100644 --- a/Library/Homebrew/test/cleanup_spec.rb +++ b/Library/Homebrew/test/cleanup_spec.rb @@ -199,11 +199,8 @@ describe Homebrew::Cleanup do describe "::cleanup_logs" do let(:path) { (HOMEBREW_LOGS/"delete_me") } - before do - path.mkpath - end - it "cleans all logs if prune is 0" do + path.mkpath described_class.new(days: 0).cleanup_logs expect(path).not_to exist end @@ -211,6 +208,7 @@ describe Homebrew::Cleanup do it "cleans up logs if older than 30 days" do allow_any_instance_of(Pathname).to receive(:ctime).and_return(31.days.ago) allow_any_instance_of(Pathname).to receive(:mtime).and_return(31.days.ago) + path.mkpath subject.cleanup_logs expect(path).not_to exist end @@ -218,6 +216,7 @@ describe Homebrew::Cleanup do it "does not clean up logs less than 30 days old" do allow_any_instance_of(Pathname).to receive(:ctime).and_return(15.days.ago) allow_any_instance_of(Pathname).to receive(:mtime).and_return(15.days.ago) + path.mkpath subject.cleanup_logs expect(path).to exist end diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 1a4bf7e1a4..df5a9906d3 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -80,6 +80,8 @@ RSpec.configure do |config| if ENV["CI"] config.verbose_retry = true config.display_try_failure_messages = true + config.default_retry_count = 2 + config.default_sleep_interval = 1 config.around(:each, :integration_test) do |example| example.metadata[:timeout] ||= 120 @@ -88,7 +90,10 @@ RSpec.configure do |config| config.around(:each, :needs_network) do |example| example.metadata[:timeout] ||= 120 - example.run_with_retry retry: 5, retry_wait: 5 + example.metadata[:retry] ||= 4 + example.metadata[:retry_wait] ||= 2 + example.metadata[:exponential_backoff] ||= true + example.run end end @@ -196,7 +201,7 @@ RSpec.configure do |config| @__stderr = $stderr.clone begin - if (example.metadata.keys & [:focus, :byebug]).empty? && !ENV.key?("VERBOSE_TESTS") + if (example.metadata.keys & [:focus, :byebug]).empty? && !ENV.key?("HOMEBREW_VERBOSE_TESTS") $stdout.reopen(File::NULL) $stderr.reopen(File::NULL) end