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