Blame SOURCES/test_dependent_scls.rb

79386f
require 'test/unit'
79386f
require 'rbconfig'
79386f
require 'rubygems'
79386f
require 'rubygems/defaults/operating_system'
79386f
79386f
class TestDependentSCLS < Test::Unit::TestCase
79386f
79386f
  def setup
79386f
    # Avoid caching
79386f
    Gem.class_eval("@default_locations, @default_dirs = nil, nil")
79386f
79386f
    # TODO: Different bin dir during build ("/builddir/build/BUILD/ruby-2.0.0-p247")
79386f
    @bin_dir = Gem::ConfigMap[:bindir].split(File::SEPARATOR).last
79386f
  end
79386f
79386f
  def test_default_paths
79386f
    default_locations = { :system => "/opt/rh/ruby200/root/usr",
79386f
                          :local  => "/opt/rh/ruby200/root/usr/local" }
79386f
    assert_equal default_locations, Gem.default_locations
79386f
79386f
    default_dirs = { :system => { :bin_dir => "/opt/rh/ruby200/root/usr/#{@bin_dir}",
79386f
                                  :gem_dir => "/opt/rh/ruby200/root/usr/share/gems",
79386f
                                  :ext_dir => "/opt/rh/ruby200/root/usr/lib64/gems" },
79386f
                     :local  => { :bin_dir => "/opt/rh/ruby200/root/usr/local/#{@bin_dir}",
79386f
                                  :gem_dir => "/opt/rh/ruby200/root/usr/local/share/gems",
79386f
                                  :ext_dir => "/opt/rh/ruby200/root/usr/local/lib64/gems" } }
79386f
    assert_equal default_dirs, Gem.default_dirs
79386f
  end
79386f
79386f
  # Gem.default_locations and Gem.default_dirs
79386f
  # should contain paths to dependent scls binary extensions
79386f
  # if the dependent scl adds itself on $GEM_PATH
79386f
  #
79386f
  # See rhbz#1034639
79386f
  def test_paths_with_dependent_scl
79386f
    prefix = '/some/prefix'
79386f
    scl_name = 'ruby_x'
79386f
79386f
    ENV['X_SCLS'] = "ruby200 #{scl_name}" # enabled scls
79386f
    ENV['GEM_PATH'] = "#{prefix}/#{scl_name}/root/usr/share/gems"
79386f
79386f
    default_locations = { :system => "/opt/rh/ruby200/root/usr",
79386f
                          :local  => "/opt/rh/ruby200/root/usr/local",
79386f
                          :"#{scl_name}_system" => "#{prefix}/#{scl_name}/root/usr",
79386f
                          :"#{scl_name}_local"  => "#{prefix}/#{scl_name}/root/usr/local" }
79386f
79386f
    assert_equal default_locations, Gem.default_locations
79386f
79386f
    default_dirs =  { :system => { :bin_dir => "/opt/rh/ruby200/root/usr/#{@bin_dir}",
79386f
                                   :gem_dir => "/opt/rh/ruby200/root/usr/share/gems",
79386f
                                   :ext_dir => "/opt/rh/ruby200/root/usr/lib64/gems" },
79386f
                      :local  => { :bin_dir => "/opt/rh/ruby200/root/usr/local/#{@bin_dir}",
79386f
                                   :gem_dir => "/opt/rh/ruby200/root/usr/local/share/gems",
79386f
                                   :ext_dir => "/opt/rh/ruby200/root/usr/local/lib64/gems" },
79386f
                      :"#{scl_name}_system" => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/#{@bin_dir}",
79386f
                                                 :gem_dir => "#{prefix}/#{scl_name}/root/usr/share/gems",
79386f
                                                 :ext_dir => "#{prefix}/#{scl_name}/root/usr/lib64/gems" },
79386f
                      :"#{scl_name}_local"  => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/local/#{@bin_dir}",
79386f
                                                 :gem_dir => "#{prefix}/#{scl_name}/root/usr/local/share/gems",
79386f
                                                 :ext_dir => "#{prefix}/#{scl_name}/root/usr/local/lib64/gems" } }
79386f
    assert_equal default_dirs, Gem.default_dirs
79386f
  end
79386f
79386f
end