summaryrefslogtreecommitdiff
path: root/spec/bundler/runtime
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-01 12:49:40 +0300
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-06-09 12:44:10 +0900
commit8f37629519ad330032a38ac0e871b2912ed38a1b (patch)
treebb0529b77583d47993d8b0d608d68896aa3a5298 /spec/bundler/runtime
parent66508992483ae5d77b56a98427c50c772341c0ac (diff)
Merge bundler master from upstream.
Pick from 8dd59e3ba97eb80a599f8149f31bf40773b69dc0
Diffstat (limited to 'spec/bundler/runtime')
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb6
-rw-r--r--spec/bundler/runtime/inline_spec.rb43
-rw-r--r--spec/bundler/runtime/require_spec.rb10
-rw-r--r--spec/bundler/runtime/setup_spec.rb50
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb35
5 files changed, 96 insertions, 48 deletions
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index 7026474b0e..eb9db56ead 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/runtime/gem_tasks_spec.rb
@@ -19,10 +19,10 @@ RSpec.describe "require 'bundler/gem_tasks'" do
it "includes the relevant tasks" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
- sys_exec "#{rake} -T"
+ sys_exec "#{rake} -T", "RUBYOPT" => "-I#{bundler_path}"
end
- expect(last_command.stderr).to eq("")
+ expect(err).to eq("")
expected_tasks = [
"rake build",
"rake clean",
@@ -39,6 +39,6 @@ RSpec.describe "require 'bundler/gem_tasks'" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
end
- expect(last_command.stdout).to eq '["pkg"]'
+ expect(out).to eq '["pkg"]'
end
end
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
index 96a3fa09ae..d53c3d1c15 100644
--- a/spec/bundler/runtime/inline_spec.rb
+++ b/spec/bundler/runtime/inline_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(last_command.stderr).to include "Could not find gem 'eleven'"
+ expect(err).to include "Could not find gem 'eleven'"
expect(out).not_to include "success"
script <<-RUBY
@@ -90,7 +90,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport")
err.gsub! %r{.*lib/sinatra/base\.rb:\d+: warning: constant ::Fixnum is deprecated$}, ""
err.strip!
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -134,7 +134,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(last_command.stderr).to include "Unknown options: arglebargle"
+ expect(err).to include "Unknown options: arglebargle"
expect(out).not_to include "success"
end
@@ -165,7 +165,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -183,7 +183,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0\n2.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -203,7 +203,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("two\nfour")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -240,6 +240,20 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
+ expect(err).to be_empty
+ expect(exitstatus).to be_zero if exitstatus
+ end
+
+ it "installs inline gems when frozen is set" do
+ script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" }
+ gemfile do
+ source "file://#{gem_repo1}"
+ gem "rack"
+ end
+
+ puts RACK
+ RUBY
+
expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -258,7 +272,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -274,6 +288,19 @@ RSpec.describe "bundler/inline#gemfile" do
puts RACK
RUBY
expect(last_command).to be_success
- expect(last_command.stdout).to eq "1.0.0"
+ expect(out).to eq "1.0.0"
+ end
+
+ it "skips platform warnings" do
+ simulate_platform "ruby"
+
+ script <<-RUBY
+ gemfile(true) do
+ source "file://#{gem_repo1}"
+ gem "rack", platform: :jruby
+ end
+ RUBY
+
+ expect(err).to be_empty
end
end
diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb
index c9cfa199d3..f149c9d489 100644
--- a/spec/bundler/runtime/require_spec.rb
+++ b/spec/bundler/runtime/require_spec.rb
@@ -136,8 +136,8 @@ RSpec.describe "Bundler.require" do
G
run "Bundler.require"
- expect(last_command.stderr).to match("error while trying to load the gem 'faulty'")
- expect(last_command.stderr).to match("Gem Internal Error Message")
+ expect(err).to match("error while trying to load the gem 'faulty'")
+ expect(err).to match("Gem Internal Error Message")
end
it "doesn't swallow the error when the library has an unrelated error" do
@@ -198,7 +198,7 @@ RSpec.describe "Bundler.require" do
RUBY
ruby(cmd)
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "does not mangle explicitly given requires" do
@@ -432,7 +432,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
G
run "Bundler.require"
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "requires gems pinned to multiple platforms, including the current one" do
@@ -447,6 +447,6 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
run "Bundler.require; puts RACK"
expect(out).to eq("1.0.0")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index c81baa34ea..90c3df8661 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
end
@@ -45,7 +45,7 @@ RSpec.describe "Bundler.setup" do
puts "WIN"
end
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("WIN")
end
@@ -58,7 +58,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
@@ -72,7 +72,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("1.0.0")
end
@@ -90,7 +90,7 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
end
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to match("WIN")
end
@@ -104,8 +104,8 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
RUBY
- expect(last_command.stderr).to match("rack")
- expect(last_command.stderr).to match("LoadError")
+ expect(err).to match("rack")
+ expect(err).to match("LoadError")
expect(out).not_to match("FAIL")
end
end
@@ -141,7 +141,7 @@ RSpec.describe "Bundler.setup" do
load_path = out.split("\n")
rack_load_order = load_path.index {|path| path.include?("rack") }
- expect(last_command.stderr).to eq("")
+ expect(err).to eq("")
expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir")
expect(rack_load_order).to be > 0
end
@@ -364,7 +364,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "replaces #gem but raises when the version is wrong" do
@@ -390,7 +390,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -449,7 +449,7 @@ RSpec.describe "Bundler.setup" do
it "provides a useful exception when the git repo is not checked out yet" do
run "1"
- expect(last_command.stderr).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
+ expect(err).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
end
it "does not hit the git binary if the lockfile is available and up to date" do
@@ -535,7 +535,7 @@ RSpec.describe "Bundler.setup" do
FileUtils.rm_rf(lib_path("local-rack"))
run "require 'rack'"
- expect(last_command.stderr).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+ expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
end
it "explodes if branch is not given on runtime" do
@@ -557,7 +557,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(last_command.stderr).to match(/because :branch is not specified in Gemfile/)
+ expect(err).to match(/because :branch is not specified in Gemfile/)
end
it "explodes on different branches on runtime" do
@@ -579,7 +579,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(last_command.stderr).to match(/is using branch master but Gemfile specifies changed/)
+ expect(err).to match(/is using branch master but Gemfile specifies changed/)
end
it "explodes on refs with different branches on runtime" do
@@ -599,7 +599,7 @@ RSpec.describe "Bundler.setup" do
bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
- expect(last_command.stderr).to match(/is using branch master but Gemfile specifies nonexistant/)
+ expect(err).to match(/is using branch master but Gemfile specifies nonexistant/)
end
end
@@ -711,7 +711,7 @@ end
ENV["GEM_HOME"] = ""
bundle %(exec ruby -e "require 'set'")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
describe "$MANPATH" do
@@ -878,7 +878,7 @@ end
require 'foo'
R
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
@@ -903,7 +903,7 @@ end
R
end
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -1053,7 +1053,7 @@ end
Bundler.load
RUBY
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
expect(out).to eq("")
end
end
@@ -1065,7 +1065,7 @@ end
G
bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
- expect(last_command.stderr).to be_empty
+ expect(err).to be_empty
end
end
@@ -1260,14 +1260,14 @@ end
it "activates no gems with -rbundler/setup" do
install_gemfile! ""
ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
it "activates no gems with bundle exec" do
install_gemfile! ""
create_file("script.rb", code)
bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
it "activates no gems with bundle exec that is loaded" do
@@ -1275,7 +1275,7 @@ end
create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
FileUtils.chmod(0o777, bundled_app("script.rb"))
bundle! "exec ./script.rb", :artifice => nil, :env => { :RUBYOPT => activation_warning_hack_rubyopt }
- expect(last_command.stdout).to eq("{}")
+ expect(out).to eq("{}")
end
let(:default_gems) do
@@ -1355,7 +1355,7 @@ end
RUBY
expect(last_command.stdboth).not_to include "FAIL"
- expect(last_command.stderr).to include "private method `gem'"
+ expect(err).to include "private method `gem'"
end
it "keeps Kernel#require private" do
@@ -1371,7 +1371,7 @@ end
RUBY
expect(last_command.stdboth).not_to include "FAIL"
- expect(last_command.stderr).to include "private method `require'"
+ expect(err).to include "private method `require'"
end
end
end
diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb
index b4503cba32..b901f28c8b 100644
--- a/spec/bundler/runtime/with_unbundled_env_spec.rb
+++ b/spec/bundler/runtime/with_unbundled_env_spec.rb
@@ -46,7 +46,7 @@ RSpec.describe "Bundler.with_env helpers" do
build_bundler_context
bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2"
end
- expect(last_command.stderr).to eq <<-EOS.strip
+ expect(err).to eq <<-EOS.strip
2 false
1 true
0 true
@@ -153,29 +153,50 @@ RSpec.describe "Bundler.with_env helpers" do
end
describe "Bundler.original_system" do
+ let(:code) do
+ <<~RUBY
+ Bundler.original_system(%([ "\$BUNDLE_FOO" = "bar" ] && exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_original_env" do
- code = 'exit Bundler.original_system(%(test "\$BUNDLE_FOO" = "bar"))'
lib = File.expand_path("../../lib", __dir__)
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(0)
+ expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.clean_system", :bundler => 2 do
+ let(:code) do
+ <<~RUBY
+ Bundler.clean_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_clean_env" do
- code = 'exit Bundler.clean_system(%(test "\$BUNDLE_FOO" = "bar"))'
lib = File.expand_path("../../lib", __dir__)
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(1)
+ expect($?.exitstatus).to eq(42)
end
end
describe "Bundler.unbundled_system" do
+ let(:code) do
+ <<~RUBY
+ Bundler.unbundled_system(%([ "\$BUNDLE_FOO" = "bar" ] || exit 42))
+
+ exit $?.exitstatus
+ RUBY
+ end
+
it "runs system inside with_unbundled_env" do
- code = 'exit Bundler.clean_system(%(test "\$BUNDLE_FOO" = "bar"))'
lib = File.expand_path("../../lib", __dir__)
system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
- expect($?.exitstatus).to eq(1)
+ expect($?.exitstatus).to eq(42)
end
end