summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Isaacks <john.isaacks@programming-perils.com>2012-12-03 19:26:07 -0500
committerJohn Isaacks <john.isaacks@programming-perils.com>2012-12-03 19:26:07 -0500
commit47202cf22054bf6c0c4665d9549da1487c9a0288 (patch)
tree568f11e8d9ee40fe694a5d377d85eac41c6805fa
parent65282d1c9ca2d0cdd6ccdbc8789608aaa2c2c101 (diff)
parent9a7099e86fea8e18a2a6a469235850f3f5bcdf7c (diff)
downloadbundler-47202cf22054bf6c0c4665d9549da1487c9a0288.tar.gz
Merge branch 'master' of github.com:carlhuda/bundler
-rw-r--r--.travis.yml6
-rw-r--r--Rakefile7
-rw-r--r--lib/bundler.rb23
-rw-r--r--spec/bundler/bundler_spec.rb48
-rw-r--r--spec/runtime/setup_spec.rb57
5 files changed, 59 insertions, 82 deletions
diff --git a/.travis.yml b/.travis.yml
index d7ce19e408..b15db8d0c4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,6 +5,7 @@ before_script:
- gem install rake -v '10.0.2'
- gem list rake
- rake --version
+ - sudo sed -i 's/1000::/1000:Travis:/g' /etc/passwd
- sudo apt-get install groff -y
- rake spec:deps
notifications:
@@ -17,16 +18,17 @@ notifications:
channels:
- "irc.freenode.org#bundler"
rvm:
- - ruby-head
- - 2.0.0
- 1.9.3
- 1.9.2
- 1.8.7
+ - 2.0.0
+ - ruby-head
# Rubygems versions MUST be available as rake tasks
# see Rakefile:66 for the list of possible RGV values
env:
- RGV=master
+ - RGV=v2.0.0.preview2
- RGV=v1.8.24
matrix:
allow_failures:
diff --git a/Rakefile b/Rakefile
index cafcfa9fa8..cd24b0f444 100644
--- a/Rakefile
+++ b/Rakefile
@@ -64,7 +64,7 @@ begin
namespace :rubygems do
# Rubygems specs by version
rubyopt = ENV["RUBYOPT"]
- %w(master v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.24 master).each do |rg|
+ %w(master v1.3.6 v1.3.7 v1.4.2 v1.5.3 v1.6.2 v1.7.2 v1.8.24 v2.0.0.preview2).each do |rg|
desc "Run specs with Rubygems #{rg}"
RSpec::Core::RakeTask.new(rg) do |t|
t.rspec_opts = %w(-fs --color)
@@ -85,9 +85,8 @@ begin
Dir.chdir("tmp/rubygems") do
system("git remote update")
- system("git checkout #{rg}")
- system("git pull origin master") if rg == "master"
- hash = `git rev-parse HEAD`.strip
+ system("git checkout origin/#{rg}")
+ hash = `git rev-parse HEAD`.chomp
end
puts "Running bundler specs against rubygems '#{rg}' at #{hash}"
diff --git a/lib/bundler.rb b/lib/bundler.rb
index e6589918c6..c3a93879ab 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -288,17 +288,12 @@ module Bundler
def load_gemspec_uncached(file)
path = Pathname.new(file)
- # Eval the gemspec from its parent directory
+ # Eval the gemspec from its parent directory, because some gemspecs
+ # depend on "./" relative paths.
Dir.chdir(path.dirname.to_s) do
- contents = File.read(path.basename.to_s)
- if contents =~ /\A---/ # try YAML
- begin
- Gem::Specification.from_yaml(contents)
- # Raises ArgumentError if the file is not valid YAML (on syck)
- # Psych raises a Psych::SyntaxError
- rescue YamlSyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
- eval_gemspec(path, contents)
- end
+ contents = path.read
+ if contents[0..2] == "---" # YAML header
+ eval_yaml_gemspec(path, contents)
else
eval_gemspec(path, contents)
end
@@ -311,6 +306,14 @@ module Bundler
private
+ def eval_yaml_gemspec(path, contents)
+ # If the YAML is invalid, Syck raises an ArgumentError, and Psych
+ # raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
+ Gem::Specification.from_yaml(contents)
+ rescue YamlSyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
+ eval_gemspec(path, contents)
+ end
+
def eval_gemspec(path, contents)
eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
rescue LoadError, SyntaxError => e
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index 8e0d87baa7..2b3abe51f5 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -3,17 +3,47 @@ require 'bundler'
describe Bundler do
describe "#load_gemspec_uncached" do
- it "should catch Psych syntax errors" do
- gemspec = <<-GEMSPEC
-{:!00 ao=gu\g1= 7~f
-GEMSPEC
- File.open(tmp("test.gemspec"), 'wb') do |file|
- file.puts gemspec
+
+ before do
+ @gemspec = tmp("test.gemspec")
+ @gemspec.open('wb') do |f|
+ f.write strip_whitespace(<<-GEMSPEC)
+ ---
+ {:!00 ao=gu\g1= 7~f
+ GEMSPEC
end
+ end
- expect(proc {
- Bundler.load_gemspec_uncached(tmp("test.gemspec"))
- }).to raise_error(Bundler::GemspecError)
+ describe "on Ruby 1.8", :ruby => "1.8" do
+ it "should catch YAML syntax errors" do
+ expect { Bundler.load_gemspec_uncached(@gemspec) }.
+ to raise_error(Bundler::GemspecError)
+ end
end
+
+ context "on Ruby 1.9", :ruby => "1.9" do
+ context "with Syck as YAML::Engine" do
+ it "raises a GemspecError after YAML load throws ArgumentError" do
+ orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'syck'
+
+ expect { Bundler.load_gemspec_uncached(@gemspec) }.
+ to raise_error(Bundler::GemspecError)
+
+ YAML::ENGINE.yamler = orig_yamler
+ end
+ end
+
+ context "with Psych as YAML::Engine" do
+ it "raises a GemspecError after YAML load throws Psych::SyntaxError" do
+ orig_yamler, YAML::ENGINE.yamler = YAML::ENGINE.yamler, 'psych'
+
+ expect { Bundler.load_gemspec_uncached(@gemspec) }.
+ to raise_error(Bundler::GemspecError)
+
+ YAML::ENGINE.yamler = orig_yamler
+ end
+ end
+ end
+
end
end
diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb
index 0ca22ca9d0..a7e5707f80 100644
--- a/spec/runtime/setup_spec.rb
+++ b/spec/runtime/setup_spec.rb
@@ -839,61 +839,4 @@ describe "Bundler.setup" do
end
end
- context "when using Syck as YAML::Engine", :ruby => "1.9" do
- it "should try to eval gemspec after YAML load throws ArgumentError" do
- orig_yamler = YAML::ENGINE.yamler
- YAML::ENGINE.yamler = 'syck'
-
- spec_file = tmp.join('temp_gemspec_to_be_loaded_with_yaml_syck')
- File.open(spec_file, 'w') do |file|
- file << strip_whitespace(<<-S)
- --- # -*- encoding: utf-8 -*-
- spec = Gem::Specification.new do |s|
- s.name = 'test'
- s.summary = %q{TODO: Write a gem summary}
- s.description = %q{TODO: Write a gem description}
- s.add_dependency 'rack', '= 1.0.1'
- s.add_development_dependency 'rspec', '1.2'
- end
- S
- end
-
- # <ArgumentError: syntax error on line 4, col 26: ` s.description = %q{TODO: Write a gem description}'>
- # should be thrown here, tried to be evaled and then fail with NoMethodError
- expect {
- Bundler.load_gemspec_uncached(tmp('temp_gemspec_to_be_loaded_with_yaml_syck'))
- }.to raise_error(NoMethodError)
-
- YAML::ENGINE.yamler = orig_yamler
- end
- end
-
- context "when using Psych as YAML::Engine", :ruby => "1.9" do
- it "should try to eval gemspec after YAML load throws Psych::SyntaxError" do
- orig_yamler = YAML::ENGINE.yamler
- YAML::ENGINE.yamler = 'psych'
-
- spec_file = tmp.join('temp_gemspec_to_be_loaded_with_yaml_psych')
- File.open(spec_file, 'w') do |file|
- file << strip_whitespace(<<-S)
- --- # -*- encoding: utf-8 -*-
- Gem::Specification.new do |s|
- s.name = 'test'
- s.summary = "TODO: Write a gem summary"
- s.description = "TODO: Write a gem description"
- s.add_dependency 'rack', '= 1.0.1'
- s.add_development_dependency 'rspec', '1.2'
- end
- S
- end
-
- # <Psych::SyntaxError: couldn't parse YAML at line 4 column 23>
- # should be thrown here, tried to be evaled and then fail with NoMethodError
- expect {
- Bundler.load_gemspec_uncached(tmp('temp_gemspec_to_be_loaded_with_yaml_psych'))
- }.to raise_error(NoMethodError)
-
- YAML::ENGINE.yamler = orig_yamler
- end
- end
end