Blame SOURCES/test_dependent_scls.rb

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