Permalink
Browse files

Cleanup after geminstalls that don't finish because of errors. Closes #…

  • Loading branch information...
Carlhuda
Carlhuda committed Dec 9, 2009
1 parent 327af9c commit 3f926f0dfce2675d5d1c936869b20a106ce07285
Showing with 29 additions and 9 deletions.
  1. +9 −2 lib/bundler/repository.rb
  2. +20 −7 spec/bundler/cli_spec.rb
View
@@ -160,6 +160,9 @@ def expand_gemfile(spec, options)
:bin_dir => @bindir
))
installer.install
+ rescue Gem::InstallError
+ cleanup_spec(spec)
+ raise
ensure
Gem::Command.build_args = []
end
@@ -189,8 +192,7 @@ def cleanup(valid, options)
to_delete.each do |spec|
Bundler.logger.info "Deleting gem: #{spec.name} (#{spec.version})"
- FileUtils.rm_rf(@path.join("specifications", "#{spec.full_name}.gemspec"))
- FileUtils.rm_rf(@path.join("gems", spec.full_name))
+ cleanup_spec(spec)
# Cleanup the bin directory
spec.executables.each do |bin|
next if valid_executables.include?(bin)
@@ -200,6 +202,11 @@ def cleanup(valid, options)
end
end
+ def cleanup_spec(spec)
+ FileUtils.rm_rf(@path.join("specifications", "#{spec.full_name}.gemspec"))
+ FileUtils.rm_rf(@path.join("gems", spec.full_name))
+ end
+
def expand(options)
each_repo do |repo|
repo.expand(options)
View
@@ -9,6 +9,13 @@
source "file://#{gem_repo1}"
gem "very_simple_binary"
Gemfile
+
+ File.open("#{bundled_app}/build.yml", "w+") do |file|
+ file.puts <<-build_options.gsub(/^ /, '')
+ very_simple_binary:
+ simple: wot
+ build_options
+ end
end
it "fails if the option is not provided" do
@@ -20,13 +27,6 @@
end
it "passes if a yaml is specified that contains the necessary options" do
- File.open("#{bundled_app}/build.yml", "w+") do |file|
- file.puts <<-build_options.gsub(/^ /, '')
- very_simple_binary:
- simple: wot
- build_options
- end
-
Dir.chdir(bundled_app) do
@output = gem_command :bundle, "--build-options=build.yml 2>&1"
end
@@ -40,6 +40,19 @@
out.should == "VerySimpleBinaryInC"
end
+
+ it "does not skip the binary gem if compiling failed in a previous bundle" do
+ Dir.chdir(bundled_app)
+
+ gem_command :bundle, "--backtrace 2>&1" # will fail
+ gem_command :bundle, "--build-options=build.yml 2>&1"
+
+ out = run_in_context <<-RUBY
+ require "very_simple_binary"
+ puts VerySimpleBinaryInC
+ RUBY
+ out.should == "VerySimpleBinaryInC"
+ end
end
describe "it working" do

0 comments on commit 3f926f0

Please sign in to comment.