diff options
author | The Bundler Bot <bot@bundler.io> | 2017-10-16 04:30:33 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-10-30 13:52:45 -0500 |
commit | bf9f327ad2272e54a64c49e6141153f8149639b4 (patch) | |
tree | 7cefde385b0fe0d5b3cf70eee603bb9d3a593584 /spec | |
parent | f9599c7e8c6775bb4044ad2b4809a957ef8fadea (diff) | |
download | bundler-bf9f327ad2272e54a64c49e6141153f8149639b4.tar.gz |
Auto merge of #6101 - bundler:seg-digest-loading, r=colby-swandale
Load digest subclasses in a thread-safe manner
The problem was `digest` files would sometimes be loaded twice.
My diagnosis was we needed to load the `digest` files using the `::Digest` method, which is explicitly thread-safe.
(cherry picked from commit 8efc35c2e2f68eae40639390b9ced72156d5d4a4)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/plugin/api/source_spec.rb | 2 | ||||
-rw-r--r-- | spec/bundler/source/rubygems/remote_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/clean_spec.rb | 6 | ||||
-rw-r--r-- | spec/plugins/source/example_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 3 | ||||
-rw-r--r-- | spec/support/artifice/compact_index.rb | 2 |
6 files changed, 9 insertions, 8 deletions
diff --git a/spec/bundler/plugin/api/source_spec.rb b/spec/bundler/plugin/api/source_spec.rb index 0118ff3d19..2c50ff56a4 100644 --- a/spec/bundler/plugin/api/source_spec.rb +++ b/spec/bundler/plugin/api/source_spec.rb @@ -36,7 +36,7 @@ RSpec.describe Bundler::Plugin::API::Source do context "install_path" do let(:uri) { "uri://to/a/repository-name" } - let(:hash) { Digest::SHA1.hexdigest(uri) } + let(:hash) { Digest(:SHA1).hexdigest(uri) } let(:install_path) { Pathname.new "/bundler/install/path" } before do diff --git a/spec/bundler/source/rubygems/remote_spec.rb b/spec/bundler/source/rubygems/remote_spec.rb index 1aa008f3bb..9a7ab42128 100644 --- a/spec/bundler/source/rubygems/remote_spec.rb +++ b/spec/bundler/source/rubygems/remote_spec.rb @@ -8,7 +8,7 @@ RSpec.describe Bundler::Source::Rubygems::Remote do end before do - allow(Digest::MD5).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" } + allow(Digest(:MD5)).to receive(:hexdigest).with(duck_type(:to_s)) {|string| "MD5HEX(#{string})" } end let(:uri_no_auth) { URI("https://gems.example.com") } diff --git a/spec/commands/clean_spec.rb b/spec/commands/clean_spec.rb index 8113ae8c25..d0df6d30d7 100644 --- a/spec/commands/clean_spec.rb +++ b/spec/commands/clean_spec.rb @@ -141,7 +141,7 @@ RSpec.describe "bundle clean" do bundle :clean - digest = Digest::SHA1.hexdigest(git_path.to_s) + digest = Digest(:SHA1).hexdigest(git_path.to_s) cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") expect(cache_path).to exist end @@ -175,7 +175,7 @@ RSpec.describe "bundle clean" do expect(vendored_gems("gems/rack-1.0.0")).to exist expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).not_to exist - digest = Digest::SHA1.hexdigest(git_path.to_s) + digest = Digest(:SHA1).hexdigest(git_path.to_s) expect(vendored_gems("cache/bundler/git/foo-#{digest}")).not_to exist expect(vendored_gems("specifications/rack-1.0.0.gemspec")).to exist @@ -254,7 +254,7 @@ RSpec.describe "bundle clean" do expect(out).to include("") expect(vendored_gems("bundler/gems/foo-#{revision[0..11]}")).to exist - digest = Digest::SHA1.hexdigest(git_path.to_s) + digest = Digest(:SHA1).hexdigest(git_path.to_s) expect(vendored_gems("cache/bundler/git/foo-#{digest}")).to_not exist end diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb index fdeec0b634..0dbd9a2a0f 100644 --- a/spec/plugins/source/example_spec.rb +++ b/spec/plugins/source/example_spec.rb @@ -142,7 +142,7 @@ RSpec.describe "real source plugins" do end describe "bundle cache/package" do - let(:uri_hash) { Digest::SHA1.hexdigest(lib_path("a-path-gem-1.0").to_s) } + let(:uri_hash) { Digest(:SHA1).hexdigest(lib_path("a-path-gem-1.0").to_s) } it "copies repository to vendor cache and uses it" do bundle "install" bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 70a0b5d1f3..cb9c764dfb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,7 +6,8 @@ $:.unshift File.expand_path("../../lib", __FILE__) require "bundler/psyched_yaml" require "bundler/vendored_fileutils" require "uri" -require "digest/sha1" +require "digest" +require File.expand_path("../support/path.rb", __FILE__) begin require "rubygems" diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb index bfb6cfd7f0..123efe3c58 100644 --- a/spec/support/artifice/compact_index.rb +++ b/spec/support/artifice/compact_index.rb @@ -15,7 +15,7 @@ class CompactIndexAPI < Endpoint def etag_response response_body = yield - checksum = Digest::MD5.hexdigest(response_body) + checksum = Digest(:MD5).hexdigest(response_body) return if not_modified?(checksum) headers "ETag" => quote(checksum) headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60" |