Permalink
Browse files

Fix the tests on 1.9

  • Loading branch information...
1 parent 5ef44d8 commit 6c43f4c0568973bf18de3861a71b4ffd90b7d15e Carlhuda committed Dec 18, 2009
@@ -77,7 +77,8 @@ def initialize(sources, source_requirements)
sources.each do |source|
source.gems.each do |name, specs|
# Hack to work with a regular Gem::SourceIndex
- [specs].flatten.compact.each do |spec|
+ specs = [specs] unless specs.is_a?(Array)
+ specs.compact.each do |spec|
next if @specs[spec.name].any? { |s| s.version == spec.version && s.platform == spec.platform }
@specs[spec.name] << spec
end
@@ -1,3 +1,3 @@
<%= shebang bin_file_name %>
-require File.join(File.dirname(__FILE__), "<%= path.join("environment").relative_path_from(Pathname.new(bin_dir)) %>")
-load File.join(File.dirname(__FILE__), "<%= path.join("gems", @spec.full_name, @spec.bindir, bin_file_name).relative_path_from(Pathname.new(bin_dir)) %>")
+require File.expand_path(File.join(File.dirname(__FILE__), "<%= path.join("environment").relative_path_from(Pathname.new(bin_dir)) %>"))
+load File.expand_path(File.join(File.dirname(__FILE__), "<%= path.join("gems", @spec.full_name, @spec.bindir, bin_file_name).relative_path_from(Pathname.new(bin_dir)) %>"))
@@ -6,6 +6,15 @@ module Bundler
<% unless options[:system_gems] -%>
ENV["GEM_HOME"] = dir
ENV["GEM_PATH"] = dir
+
+ # handle 1.9 where system gems are always on the load path
+ if defined?(::Gem)
+ $LOAD_PATH.reject! do |p|
+ p != File.dirname(__FILE__) &&
+ Gem.path.any? { |gp| p.include?(gp) }
+ end
+ end
+
<% end -%>
ENV["PATH"] = "#{dir}/<%= bindir %><%= File::PATH_SEPARATOR %>#{ENV["PATH"]}"
ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}"
@@ -34,7 +34,7 @@
@output.should_not =~ /Failed to build gem native extension/
out = run_in_context <<-RUBY
- require 'very_simple_binary'
+ require 'very_simple_binary_c'
puts VerySimpleBinaryInC
RUBY
@@ -48,7 +48,7 @@
gem_command :bundle, "--build-options=build.yml 2>&1"
out = run_in_context <<-RUBY
- require "very_simple_binary"
+ require "very_simple_binary_c"
puts VerySimpleBinaryInC
RUBY
out.should == "VerySimpleBinaryInC"
@@ -373,7 +373,7 @@
clear_sources
source "file://#{gem_repo1}"
gem "activesupport"
- gem "rake", :only => :server
+ gem "very-simple", :only => :server
gem "rack", :only => :test
Gemfile
end
@@ -386,7 +386,7 @@
out.should == "2.3.2"
out = run_in_context <<-RUBY
- begin ;require 'rake'
+ begin ;require 'very-simple'
rescue LoadError ; puts 'awesome' ; end
RUBY
out.should == 'awesome'
@@ -115,16 +115,18 @@
end
it "it does not work with system gems if system gems have been disabled" do
- m = build_manifest <<-Gemfile
- clear_sources
- source "file://#{gem_repo1}"
- gem "rack"
- disable_system_gems
- Gemfile
-
- m.install
- out = run_in_context "begin ; require 'spec' ; rescue LoadError ; puts('WIN') ; end"
- out.should == "WIN"
+ system_gems 'rspec-1.2.7' do
+ m = build_manifest <<-Gemfile
+ clear_sources
+ source "file://#{gem_repo1}"
+ gem "rack"
+ disable_system_gems
+ Gemfile
+
+ m.install
+ out = run_in_context "begin ; require 'spec' ; rescue LoadError ; puts('WIN') ; end"
+ out.should == "WIN"
+ end
end
["Running with system gems", "Running without system gems"].each_with_index do |desc, i|
@@ -69,14 +69,14 @@ def build_repo1
exit 1 unless with_config("simple")
- extension_name = "very_simple_binary"
+ extension_name = "very_simple_binary_c"
dir_config extension_name
create_makefile extension_name
RUBY
s.write "ext/very_simple_binary.c", <<-C
#include "ruby.h"
- void Init_very_simple_binary() {
+ void Init_very_simple_binary_c() {
rb_define_module("VerySimpleBinaryInC");
}
C
@@ -8,6 +8,7 @@ def run_in_context(cmd)
def ruby(opts, ruby = nil)
ruby, opts = opts, nil unless ruby
ruby.gsub!(/(?=")/, "\\")
+ ruby.gsub!('$', '\\$')
lib = File.join(File.dirname(__FILE__), '..', '..', 'lib')
%x{#{Gem.ruby} -I#{lib} #{opts} -e "#{ruby}"}.strip
end

0 comments on commit 6c43f4c

Please sign in to comment.