Blame SOURCES/test_dependent_scls.rb

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