summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-03-27 19:47:41 +0000
committerColby Swandale <me@colby.fyi>2018-10-05 16:15:43 +1000
commit9256ce883bd0fbfff229d5f24ee08018fe4edfb5 (patch)
treea0d4736dfcf4a825d0a139d7e79ecd3a0fbaee60 /spec
parent15dec01a1b38d3c22241d9ad9e8bf3a10e55d2a3 (diff)
downloadbundler-9256ce883bd0fbfff229d5f24ee08018fe4edfb5.tar.gz
Auto merge of #6305 - wagenet:fix-git-pristine, r=indirect
Correctly re-install extensions when running `pristine` for a git source ### What was the end-user problem that led to this PR? I have a gem with a native extension that is installed via git. I had to recompile it due to some needed build arguments. ### The problem was... Running `bundle pristine` would not recompile it as expected. ### My diagnosis was... After digging into the source, I discovered that the built extension lived in a different location than the cloned git repo. `bundle pristine` was only removing the git repo so the built extension was not getting rebuilt. ### My fix... Update `bundle pristine` to also remove the built extension. For 2.0, this also required removing the built extension cache. Without doing that, the built extension directory would just be recreated from the cache. ### I chose this fix because... As far as I know, it's the only solution. Resolves #6294 (cherry picked from commit 77dbd12d0759ca635e3cb5cb0e90840cdac7f0d0)
Diffstat (limited to 'spec')
-rw-r--r--spec/commands/pristine_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb
index 140b111d2d..a780cbfb5b 100644
--- a/spec/commands/pristine_spec.rb
+++ b/spec/commands/pristine_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe "bundle pristine" do
build_gem "baz-dev", "1.0.0"
build_gem "very_simple_binary", &:add_c_extension
build_git "foo", :path => lib_path("foo")
+ build_git "git_with_ext", :path => lib_path("git_with_ext"), &:add_c_extension
build_lib "bar", :path => lib_path("bar")
end
@@ -22,6 +23,7 @@ RSpec.describe "bundle pristine" do
gem "weakling"
gem "very_simple_binary"
gem "foo", :git => "#{lib_path("foo")}"
+ gem "git_with_ext", :git => "#{lib_path("git_with_ext")}"
gem "bar", :path => "#{lib_path("bar")}"
gemspec
@@ -170,4 +172,21 @@ RSpec.describe "bundle pristine" do
expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
end
end
+
+ context "when a build config exists for a git sourced gem" do
+ let(:git_with_ext) { Bundler.definition.specs["git_with_ext"].first }
+ let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") }
+ let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
+ before { bundle "config build.git_with_ext -- #{build_opt}" }
+
+ # This just verifies that the generated Makefile from the c_ext gem makes
+ # use of the build_args from the bundle config
+ it "applies the config when installing the gem" do
+ bundle! "pristine"
+
+ makefile_contents = File.read(c_ext_dir.join("Makefile").to_s)
+ expect(makefile_contents).to match(/libpath =.*#{c_ext_dir}/)
+ expect(makefile_contents).to match(/LIBPATH =.*-L#{c_ext_dir}/)
+ end
+ end
end