summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-12-26 16:47:45 -0600
committerSamuel Giddins <segiddins@segiddins.me>2016-12-26 16:47:45 -0600
commite86631c1d2b0b5073c4f29ed7cc262f61932aa01 (patch)
treebcad9661b6dd9de051488c7140a6a222d059d675
parentedf6cab6b83a3528b71609c33131a88611ca38e4 (diff)
downloadbundler-seg-parallel-installer-missing-specs-warning.tar.gz
Add specs for falling back to 1 thread when the lockfile is corruptseg-parallel-installer-missing-specs-warning
-rw-r--r--lib/bundler/installer/parallel_installer.rb2
-rw-r--r--spec/bundler/installer/parallel_installer_spec.rb47
-rw-r--r--spec/bundler/installer/spec_installation_spec.rb (renamed from spec/install/parallel/spec_installation_spec.rb)15
3 files changed, 49 insertions, 15 deletions
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 9e3a8d51f7..70939ceeb7 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -78,6 +78,8 @@ module Bundler
[Bundler.settings[:jobs].to_i - 1, 1].max
end
+ attr_reader :size
+
def initialize(installer, all_specs, size, standalone, force)
@installer = installer
@size = size
diff --git a/spec/bundler/installer/parallel_installer_spec.rb b/spec/bundler/installer/parallel_installer_spec.rb
new file mode 100644
index 0000000000..0f4e7dba9a
--- /dev/null
+++ b/spec/bundler/installer/parallel_installer_spec.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+require "spec_helper"
+require "bundler/installer/parallel_installer"
+
+describe Bundler::ParallelInstaller do
+ let(:installer) { instance_double("Installer") }
+ let(:all_specs) { [] }
+ let(:size) { 1 }
+ let(:standalone) { false }
+ let(:force) { false }
+
+ subject { described_class.new(installer, all_specs, size, standalone, force) }
+
+ context "when dependencies that are not on the overall installation list are the only ones not installed" do
+ let(:all_specs) do
+ [
+ build_spec("alpha", "1.0") {|s| s.runtime "a", "1" },
+ ].flatten
+ end
+
+ it "prints a warning" do
+ expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
+Your lockfile was created by an old Bundler that left some things out.
+You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile.
+The missing gems are:
+* a depended upon by alpha
+ W
+ subject.check_for_corrupt_lockfile
+ end
+
+ context "when size > 1" do
+ let(:size) { 500 }
+
+ it "prints a warning and sets size to 1" do
+ expect(Bundler.ui).to receive(:warn).with(<<-W.strip)
+Your lockfile was created by an old Bundler that left some things out.
+Because of the missing DEPENDENCIES, we can only install gems one at a time, instead of installing 500 at a time.
+You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile.
+The missing gems are:
+* a depended upon by alpha
+ W
+ subject.check_for_corrupt_lockfile
+ expect(subject.size).to eq(1)
+ end
+ end
+ end
+end
diff --git a/spec/install/parallel/spec_installation_spec.rb b/spec/bundler/installer/spec_installation_spec.rb
index 7bbd2bd0e6..b18695bf26 100644
--- a/spec/install/parallel/spec_installation_spec.rb
+++ b/spec/bundler/installer/spec_installation_spec.rb
@@ -58,20 +58,5 @@ describe Bundler::ParallelInstaller::SpecInstallation do
expect(spec.dependencies_installed?(all_specs)).to be_falsey
end
end
-
- context "when dependencies that are not on the overall installation list are the only ones not installed" do
- it "raises an error" do
- dependencies = []
- dependencies << instance_double("SpecInstallation", :spec => "alpha", :name => "alpha", :installed? => true, :all_dependencies => [], :type => :production)
- all_specs = dependencies + [instance_double("SpecInstallation", :spec => "gamma", :name => "gamma", :installed? => false, :all_dependencies => [], :type => :production)]
- # Add dependency which is not in all_specs
- dependencies << instance_double("SpecInstallation", :spec => "beta", :name => "beta", :installed? => false, :all_dependencies => [], :type => :production)
- dependencies << instance_double("SpecInstallation", :spec => "delta", :name => "delta", :installed? => false, :all_dependencies => [], :type => :production)
- spec = described_class.new(dep)
- allow(spec).to receive(:all_dependencies).and_return(dependencies)
- expect { spec.dependencies_installed?(all_specs) }.
- to raise_error(Bundler::LockfileError, /Your Gemfile.lock is corrupt\. The following.*'beta' 'delta'/)
- end
- end
end
end