1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[bundler/bundler] Always set cache_all via config during tests

So that the behavior is the same regardless of the tested bundler
version.

664549427a
This commit is contained in:
David Rodríguez 2019-07-23 17:32:33 +02:00 committed by Hiroshi SHIBATA
parent 267a72be80
commit 2b7e39f364
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
7 changed files with 60 additions and 31 deletions

View file

@ -22,7 +22,8 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}' gem "foo", :git => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file
@ -40,7 +41,8 @@ end
G G
bundle "install --path vendor/bundle" bundle "install --path vendor/bundle"
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
@ -56,8 +58,9 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}' gem "foo", :git => '#{lib_path("foo-1.0")}'
G G
bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle! cmd
bundle! cmd
expect(out).to include "Updating files in vendor/cache" expect(out).to include "Updating files in vendor/cache"
FileUtils.rm_rf lib_path("foo-1.0") FileUtils.rm_rf lib_path("foo-1.0")
@ -72,7 +75,8 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}' gem "foo", :git => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
update_git "foo" do |s| update_git "foo" do |s|
s.write "lib/foo.rb", "puts :CACHE" s.write "lib/foo.rb", "puts :CACHE"
@ -82,7 +86,8 @@ end
expect(ref).not_to eq(old_ref) expect(ref).not_to eq(old_ref)
bundle! "update", :all => true bundle! "update", :all => true
bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! cmd
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{old_ref}")).not_to exist
@ -100,7 +105,8 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}' gem "foo", :git => '#{lib_path("foo-1.0")}'
G G
bundle! cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! cmd
update_git "foo" do |s| update_git "foo" do |s|
s.write "lib/foo.rb", "puts :CACHE" s.write "lib/foo.rb", "puts :CACHE"
@ -129,7 +135,8 @@ end
bundle %(config set local.foo #{lib_path("foo-1.0")}) bundle %(config set local.foo #{lib_path("foo-1.0")})
bundle "install" bundle "install"
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-invalid-#{ref}")).to exist
@ -161,7 +168,8 @@ end
G G
ref = git.ref_for("master", 11) ref = git.ref_for("master", 11)
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist expect(bundled_app("vendor/cache/has_submodule-1.0-#{ref}/submodule-1.0")).to exist
@ -187,7 +195,8 @@ end
gem "foo", :git => '#{lib_path("foo-1.0")}' gem "foo", :git => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
bundle cmd bundle cmd
expect(err).not_to include("Your Gemfile contains path and git dependencies.") expect(err).not_to include("Your Gemfile contains path and git dependencies.")
@ -204,7 +213,8 @@ end
install_gemfile <<-G install_gemfile <<-G
gem "foo", :git => '#{lib_path("foo-1.0")}' gem "foo", :git => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
ref = git.ref_for("master", 11) ref = git.ref_for("master", 11)
gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read gemspec = bundled_app("vendor/cache/foo-1.0-#{ref}/foo.gemspec").read

View file

@ -9,7 +9,8 @@
gem "foo", :path => '#{bundled_app("lib/foo")}' gem "foo", :path => '#{bundled_app("lib/foo")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
expect(the_bundle).to include_gems "foo 1.0" expect(the_bundle).to include_gems "foo 1.0"
end end
@ -21,7 +22,8 @@
gem "foo", :path => '#{lib_path("foo-1.0")}' gem "foo", :path => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/foo-1.0")).to exist expect(bundled_app("vendor/cache/foo-1.0")).to exist
expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file expect(bundled_app("vendor/cache/foo-1.0/.bundlecache")).to be_file
@ -39,7 +41,8 @@
gem "#{libname}", :path => '#{libpath}' gem "#{libname}", :path => '#{libpath}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
expect(bundled_app("vendor/cache/#{libname}")).to exist expect(bundled_app("vendor/cache/#{libname}")).to exist
expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file expect(bundled_app("vendor/cache/#{libname}/.bundlecache")).to be_file
@ -54,13 +57,14 @@
gem "foo", :path => '#{lib_path("foo-1.0")}' gem "foo", :path => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
build_lib "foo" do |s| build_lib "foo" do |s|
s.write "lib/foo.rb", "puts :CACHE" s.write "lib/foo.rb", "puts :CACHE"
end end
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle cmd
expect(bundled_app("vendor/cache/foo-1.0")).to exist expect(bundled_app("vendor/cache/foo-1.0")).to exist
FileUtils.rm_rf lib_path("foo-1.0") FileUtils.rm_rf lib_path("foo-1.0")
@ -76,13 +80,14 @@
gem "foo", :path => '#{lib_path("foo-1.0")}' gem "foo", :path => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
install_gemfile <<-G install_gemfile <<-G
gem "bar", :path => '#{lib_path("bar-1.0")}' gem "bar", :path => '#{lib_path("bar-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle cmd
expect(bundled_app("vendor/cache/bar-1.0")).not_to exist expect(bundled_app("vendor/cache/bar-1.0")).not_to exist
end end
@ -105,7 +110,8 @@
gem "foo", :path => '#{lib_path("foo-1.0")}' gem "foo", :path => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
build_lib "bar" build_lib "bar"
install_gemfile <<-G install_gemfile <<-G
@ -124,7 +130,8 @@
gem "foo", :path => '#{lib_path("foo-1.0")}' gem "foo", :path => '#{lib_path("foo-1.0")}'
G G
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle cmd
build_lib "baz" build_lib "baz"
gemfile <<-G gemfile <<-G

View file

@ -24,7 +24,8 @@ RSpec.describe "bundle package" do
gem 'bundler' gem 'bundler'
D D
bundle :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle :package
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
@ -54,7 +55,8 @@ RSpec.describe "bundle package" do
gemspec gemspec
D D
bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! :package
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
@ -85,7 +87,8 @@ RSpec.describe "bundle package" do
gemspec gemspec
D D
bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! :package
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
@ -129,7 +132,8 @@ RSpec.describe "bundle package" do
gemspec :name => 'mygem_test' gemspec :name => 'mygem_test'
D D
bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! :package
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist

View file

@ -388,7 +388,9 @@ You have deleted from the Gemfile:
bundle! :install bundle! :install
expect(the_bundle).to include_gems "foo 1.0" expect(the_bundle).to include_gems "foo 1.0"
bundle! :package, forgotten_command_line_options([:all, :cache_all] => true)
bundle "config set cache_all true"
bundle! :package
expect(bundled_app("vendor/cache/foo")).to be_directory expect(bundled_app("vendor/cache/foo")).to be_directory
bundle! "install --local" bundle! "install --local"

View file

@ -1390,7 +1390,8 @@ In Gemfile:
gem 'foo' gem 'foo'
end end
G G
bundle :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle :package
simulate_new_machine simulate_new_machine
bundle! "install", :env => { "PATH" => "" } bundle! "install", :env => { "PATH" => "" }

View file

@ -620,7 +620,8 @@ RSpec.describe "the lockfile format" do
gem "foo", :path => "#{lib_path("foo-1.0")}" gem "foo", :path => "#{lib_path("foo-1.0")}"
G G
bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! :package
bundle! :install, :local => true bundle! :install, :local => true
lockfile_should_be <<-G lockfile_should_be <<-G

View file

@ -145,7 +145,8 @@ RSpec.describe "real source plugins" 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 it "copies repository to vendor cache and uses it" do
bundle "install" bundle "install"
bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle :cache
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}/.git")).not_to exist expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}/.git")).not_to exist
@ -157,7 +158,8 @@ RSpec.describe "real source plugins" do
it "copies repository to vendor cache and uses it even when installed with bundle --path" do it "copies repository to vendor cache and uses it even when installed with bundle --path" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle") bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
bundle! :cache, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! :cache
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
@ -167,7 +169,8 @@ RSpec.describe "real source plugins" do
it "bundler package copies repository to vendor cache" do it "bundler package copies repository to vendor cache" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle") bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
bundle! :package, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle! :package
expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist expect(bundled_app("vendor/cache/a-path-gem-1.0-#{uri_hash}")).to exist
@ -492,7 +495,8 @@ RSpec.describe "real source plugins" do
end end
G G
bundle :cache, forgotten_command_line_options([:all, :cache_all] => true) bundle "config set cache_all true"
bundle :cache
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.git")).not_to exist
expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file expect(bundled_app("vendor/cache/foo-1.0-#{ref}/.bundlecache")).to be_file