diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-30 18:45:10 +0200 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-07-05 14:12:47 +0200 |
commit | 0a201f40bc1a8276e529d60812f59a21b0b99138 (patch) | |
tree | 1b94ab51acaf17432b784fcfbe482a5d95cea43d /spec | |
parent | 128e070e181fd617192c2df6a09974f2344f23d4 (diff) | |
download | bundler-0a201f40bc1a8276e529d60812f59a21b0b99138.tar.gz |
Update specs for the specific platform being added to the lockfile
Also ensure the resolver processes specs in the correct order for error messages
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/definition_spec.rb | 6 | ||||
-rw-r--r-- | spec/commands/check_spec.rb | 2 | ||||
-rw-r--r-- | spec/commands/install_spec.rb | 4 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 16 | ||||
-rw-r--r-- | spec/commands/update_spec.rb | 6 | ||||
-rw-r--r-- | spec/install/gems/flex_spec.rb | 2 | ||||
-rw-r--r-- | spec/lock/lockfile_spec.rb | 111 | ||||
-rw-r--r-- | spec/plugins/source/example_spec.rb | 4 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/command_execution.rb | 5 | ||||
-rw-r--r-- | spec/support/platforms.rb | 13 | ||||
-rw-r--r-- | spec/update/git_spec.rb | 2 |
12 files changed, 97 insertions, 78 deletions
diff --git a/spec/bundler/definition_spec.rb b/spec/bundler/definition_spec.rb index 4bc6b23106..b9fb178afd 100644 --- a/spec/bundler/definition_spec.rb +++ b/spec/bundler/definition_spec.rb @@ -97,7 +97,7 @@ RSpec.describe Bundler::Definition do rack (= 1.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES foo! @@ -171,7 +171,7 @@ RSpec.describe Bundler::Definition do rack (= 1.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES foo! @@ -197,7 +197,7 @@ RSpec.describe Bundler::Definition do foo (1.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES foo diff --git a/spec/commands/check_spec.rb b/spec/commands/check_spec.rb index 324959c0e0..bed9fa1aa9 100644 --- a/spec/commands/check_spec.rb +++ b/spec/commands/check_spec.rb @@ -297,7 +297,7 @@ RSpec.describe "bundle check" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index 0e4d291210..a21b735f8e 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -401,7 +401,7 @@ RSpec.describe "bundle install with gem sources" do specs: PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES @@ -425,7 +425,7 @@ RSpec.describe "bundle install with gem sources" do specs: PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index 83bd233d6d..b16a828cad 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -43,7 +43,7 @@ RSpec.describe "bundle lock" do with_license (1.0) PLATFORMS - #{local} + #{lockfile_platforms} DEPENDENCIES foo @@ -58,7 +58,7 @@ RSpec.describe "bundle lock" do it "prints a lockfile when there is no existing lockfile with --print" do bundle "lock --print" - expect(out).to include(@lockfile) + expect(out).to eq(@lockfile) end it "prints a lockfile when there is an existing lockfile with --print" do @@ -166,13 +166,13 @@ RSpec.describe "bundle lock" do bundle! "lock --add-platform java x86-mingw32" lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to eq([java, local, mingw]) + expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq) end it "supports adding the `ruby` platform" do bundle! "lock --add-platform ruby" lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to eq([local, "ruby"].uniq) + expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq) end it "warns when adding an unknown platform" do @@ -184,17 +184,17 @@ RSpec.describe "bundle lock" do bundle! "lock --add-platform java x86-mingw32" lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to eq([java, local, mingw]) + expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq) bundle! "lock --remove-platform java" lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to eq([local, mingw]) + expect(lockfile.platforms).to match_array(local_platforms.unshift(mingw).uniq) end it "errors when removing all platforms" do - bundle "lock --remove-platform #{local}" - expect(out).to include("Removing all platforms from the bundle is not allowed") + bundle "lock --remove-platform #{local_platforms.join(" ")}" + expect(last_command.bundler_err).to include("Removing all platforms from the bundle is not allowed") end # from https://github.com/bundler/bundler/issues/4896 diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index eb6d2382cf..a0f0245046 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -520,7 +520,7 @@ RSpec.describe "bundle update --ruby" do specs: PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES @@ -546,7 +546,7 @@ RSpec.describe "bundle update --ruby" do specs: PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES @@ -590,7 +590,7 @@ RSpec.describe "bundle update --ruby" do specs: PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES diff --git a/spec/install/gems/flex_spec.rb b/spec/install/gems/flex_spec.rb index d0f7c0af79..f6af806154 100644 --- a/spec/install/gems/flex_spec.rb +++ b/spec/install/gems/flex_spec.rb @@ -299,7 +299,7 @@ RSpec.describe "bundle flex_install" do specs: PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index a502e4a282..d1b415395a 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -17,7 +17,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -40,7 +40,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES omg! @@ -63,7 +63,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -83,7 +83,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -105,7 +105,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -123,7 +123,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -142,7 +142,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack (> 0) @@ -179,7 +179,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do warning_message = "the running version of Bundler (9999999.0.0) is older " \ "than the version that created the lockfile (9999999.1.0)" - expect(out.scan(warning_message).size).to eq(1) + expect(last_command.bundler_err).to include warning_message lockfile_should_be <<-G GEM @@ -188,7 +188,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -206,7 +206,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -221,8 +221,8 @@ RSpec.describe "the lockfile format", :bundler => "2" do gem "rack" G - expect(exitstatus > 0) if exitstatus - expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.") + expect(last_command).to be_failure + expect(last_command.bundler_err).to include("You must use Bundler 9999999 or greater with this lockfile.") end it "shows a friendly error when running with a new bundler 2 lockfile" do @@ -259,7 +259,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do end G - expect(exitstatus > 0) if exitstatus + expect(last_command).to be_failure expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.") end @@ -298,7 +298,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -324,7 +324,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack-obama @@ -350,7 +350,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack-obama (>= 1.0) @@ -389,7 +389,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack-obama (>= 1.0)! @@ -414,7 +414,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do net-ssh (1.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES net-sftp @@ -444,7 +444,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do specs: PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -472,7 +472,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -517,7 +517,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do #{Bundler::VERSION} L - bundle "install" + bundle! "install" expect(the_bundle).to include_gems "rack 1.0.0" end @@ -541,7 +541,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -571,7 +571,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -601,7 +601,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -628,7 +628,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -658,7 +658,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -698,7 +698,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES bar! @@ -733,7 +733,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES actionpack @@ -774,7 +774,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rake (10.0.2) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rails @@ -800,7 +800,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do net-ssh (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES double_deps @@ -826,7 +826,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack-obama (>= 1.0) @@ -852,7 +852,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack-obama (>= 1.0) @@ -881,7 +881,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -910,7 +910,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -939,7 +939,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -966,7 +966,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do foo (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES foo! @@ -999,8 +999,6 @@ RSpec.describe "the lockfile format", :bundler => "2" do gem "rack" G - platforms = ["java", generic_local_platform.to_s].sort - lockfile_should_be <<-G GEM remote: file:#{gem_repo1}/ @@ -1008,8 +1006,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - #{platforms[0]} - #{platforms[1]} + #{lockfile_platforms "java", generic_local_platform, specific_local_platform} DEPENDENCIES rack @@ -1020,25 +1017,29 @@ RSpec.describe "the lockfile format", :bundler => "2" do end it "persists the spec's platform to the lockfile" do - build_gem "platform_specific", "1.0.0", :to_system => true do |s| - s.platform = Gem::Platform.new("universal-java-16") + build_repo2 do + build_gem "platform_specific", "1.0" do |s| + s.platform = Gem::Platform.new("universal-java-16") + end end simulate_platform "universal-java-16" - install_gemfile <<-G - source "file://#{gem_repo1}" + install_gemfile! <<-G + source "file://#{gem_repo2}" gem "platform_specific" G lockfile_should_be <<-G GEM - remote: file:#{gem_repo1}/ + remote: file:#{gem_repo2}/ specs: platform_specific (1.0-java) + platform_specific (1.0-universal-java-16) PLATFORMS java + universal-java-16 DEPENDENCIES platform_specific @@ -1068,7 +1069,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES activesupport @@ -1093,7 +1094,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack @@ -1117,7 +1118,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack (= 1.0) @@ -1141,7 +1142,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (1.0.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack (= 1.0) @@ -1186,7 +1187,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (0.9.1) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack (> 0.9, < 1.0) @@ -1210,7 +1211,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack (0.9.1) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack (> 0.9, < 1.0) @@ -1262,7 +1263,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do omg (1.0) PLATFORMS - #{local} + #{lockfile_platforms} DEPENDENCIES omg! @@ -1289,7 +1290,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do omg (1.0) PLATFORMS - #{local} + #{lockfile_platforms} DEPENDENCIES omg! @@ -1307,7 +1308,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do rack_middleware (1.0) PLATFORMS - #{local} + #{lockfile_platforms} DEPENDENCIES rack_middleware @@ -1402,7 +1403,7 @@ RSpec.describe "the lockfile format", :bundler => "2" do >>>>>>> PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES rack diff --git a/spec/plugins/source/example_spec.rb b/spec/plugins/source/example_spec.rb index d956a0571b..b00c5b66d7 100644 --- a/spec/plugins/source/example_spec.rb +++ b/spec/plugins/source/example_spec.rb @@ -103,7 +103,7 @@ RSpec.describe "real source plugins" do a-path-gem (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES a-path-gem! @@ -395,7 +395,7 @@ RSpec.describe "real source plugins" do ma-gitp-gem (1.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES ma-gitp-gem! diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 5fcbd4eb45..3025b502ae 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1092,7 +1092,7 @@ end rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack @@ -1150,7 +1150,7 @@ end rack (1.0.0) PLATFORMS - #{generic_local_platform} + #{lockfile_platforms} DEPENDENCIES rack diff --git a/spec/support/command_execution.rb b/spec/support/command_execution.rb index bb067d6293..5b58a52117 100644 --- a/spec/support/command_execution.rb +++ b/spec/support/command_execution.rb @@ -36,5 +36,10 @@ module Spec return true unless exitstatus exitstatus == 0 end + + def failure? + return true unless exitstatus + exitstatus > 0 + end end end diff --git a/spec/support/platforms.rb b/spec/support/platforms.rb index 8d4a21d2d2..61b8066865 100644 --- a/spec/support/platforms.rb +++ b/spec/support/platforms.rb @@ -98,5 +98,18 @@ module Spec def not_local_patchlevel 9999 end + + def lockfile_platforms(*platforms) + platforms = local_platforms if platforms.empty? + platforms.map(&:to_s).sort.join("\n ") + end + + def local_platforms + if Bundler::VERSION.split(".").first.to_i > 1 + [local, specific_local_platform] + else + [local] + end + end end end diff --git a/spec/update/git_spec.rb b/spec/update/git_spec.rb index 2b12713198..b8f98ade27 100644 --- a/spec/update/git_spec.rb +++ b/spec/update/git_spec.rb @@ -354,7 +354,7 @@ RSpec.describe "bundle update" do foo (2.0) PLATFORMS - ruby + #{lockfile_platforms} DEPENDENCIES foo! |