diff --git a/Library/Homebrew/downloadable.rb b/Library/Homebrew/downloadable.rb index 9d732e237a..c352191c8e 100644 --- a/Library/Homebrew/downloadable.rb +++ b/Library/Homebrew/downloadable.rb @@ -132,6 +132,26 @@ module Downloadable EOS end + sig { returns(Integer) } + def hash + [self.class, cached_download].hash + end + + sig { params(other: Object).returns(T::Boolean) } + def eql?(other) + return false if self.class != other.class + + other = T.cast(other, Downloadable) + cached_download == other.cached_download + end + + sig { returns(String) } + def to_s + short_cached_download = cached_download.to_s + .delete_prefix("#{HOMEBREW_CACHE}/downloads/") + "#<#{self.class}: #{short_cached_download}>" + end + private sig { overridable.returns(String) } diff --git a/Library/Homebrew/test/cmd/fetch_spec.rb b/Library/Homebrew/test/cmd/fetch_spec.rb index f63c977f9b..b8a8241ca0 100644 --- a/Library/Homebrew/test/cmd/fetch_spec.rb +++ b/Library/Homebrew/test/cmd/fetch_spec.rb @@ -26,14 +26,4 @@ RSpec.describe Homebrew::Cmd::FetchCmd do expect(HOMEBREW_CACHE/"testball2--0.1.tbz").to be_a_symlink expect(HOMEBREW_CACHE/"testball2--0.1.tbz").to exist end - - it "errors when concurrently downloading to the same destination", :integration_test do - # This test will fail if the fetch is not performed concurrently. - # N.B. this test relies on how we set up test formulae, see the `integration_test` shared context. - setup_test_formula "testball1" - setup_test_formula "testball3" - - expect { brew "fetch", "testball1", "testball3", "HOMEBREW_DOWNLOAD_CONCURRENCY" => "2" }.to be_a_failure - .and output(/Error:.*process has already locked/).to_stderr - end end