Fix: do not fail in operating_system.rb when X_SCLS is empty

Enhance test_dependent_scls.rb

Resolves: rhbz#1387139
This commit is contained in:
Pavel Valena 2016-10-26 20:04:45 +02:00
parent da60d77e08
commit f148354cb2
3 changed files with 74 additions and 38 deletions

View File

@ -42,7 +42,11 @@ module Gem
# Get enabled SCLs in order of (most) dependent SCL to base SCL
def x_scls
@x_scls ||= ENV['X_SCLS'].split(' ').reverse!
@x_scls ||= if ENV['X_SCLS'].kind_of?(String)
ENV['X_SCLS'].split(' ').reverse!
else
[]
end
end
private :x_scls

View File

@ -23,7 +23,7 @@
%global ruby_archive %{ruby_archive}-%{?milestone}%{?!milestone:%{?revision:r%{revision}}}
%endif
%global release 63
%global release 64
%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}}
# The RubyGems library has to stay out of Ruby directory three, since the
@ -632,10 +632,12 @@ sed -i 's/^/%lang(ja) /' .ruby-doc.ja
%check
# Ruby software collection tests
%{?scl:scl enable %scl - << \EOF
set -e
mkdir -p ./lib/rubygems/defaults
cp %{SOURCE1} ./lib/rubygems/defaults
make test-all TESTS="%{SOURCE14}" || exit 1
rm -rf ./lib/rubygems/defaults
sed 's/@SCL@/%{scl}/' %{SOURCE14} > ./%{basename:%{SOURCE14}}
make test-all TESTS="%{basename:%{SOURCE14}}"
rm -rf ./lib/rubygems/defaults ./%{basename:%{SOURCE14}}
EOF}
# Check RubyGems version correctness.
@ -963,7 +965,11 @@ make check TESTS="-v $DISABLE_TESTS"
%{ruby_libdir}/tkextlib
%changelog
* Mon Oct 17 2016 Pavel Valena <pvalena@redhat.com>
* Wed Oct 26 2016 Pavel Valena <pvalena@redhat.com> - 2.3.1-64
- Fix: do not fail in operating_system.rb when X_SCLS is empty
Resolves: rhbz#1387139
* Mon Oct 17 2016 Pavel Valena <pvalena@redhat.com> - 2.3.1-63
- Support in no_proxy for domain names with whitespaces and leading dots
Resolves: rhbz#1384810

View File

@ -6,25 +6,36 @@ require 'rubygems/defaults/operating_system'
class TestDependentSCLS < Test::Unit::TestCase
def setup
# Avoid caching
Gem.class_eval("@x_scls, @default_locations, @default_dirs = nil, nil, nil")
# TODO: Different bin dir during build ("/builddir/build/BUILD/ruby-2.0.0-p247")
@bin_dir = Gem::ConfigMap[:bindir].split(File::SEPARATOR).last
@scl = ENV['X_SCLS'].strip
@scl_root = '/opt/rh/@SCL@/root'
@env_orig = ['X_SCLS', 'GEM_PATH'].inject({}) do |env_orig, key|
env_orig[key] = ENV[key].dup
env_orig
end
end
def teardown
# Avoid caching
Gem.class_eval("@x_scls, @default_locations, @default_dirs, @get_default_dirs = nil, nil, nil, nil")
@env_orig.each { |key, val| ENV[key] = val }
end
def test_default_paths
default_locations = { :system => "/opt/rh/#{@scl}/root/usr",
:local => "/opt/rh/#{@scl}/root/usr/local" }
ENV['X_SCLS'] = '@SCL@' # enabled scls
default_locations = { :system => "#{@scl_root}/usr",
:local => "#{@scl_root}/usr/local" }
assert_equal default_locations, Gem.default_locations
default_dirs = { :system => { :bin_dir => "/opt/rh/#{@scl}/root/usr/#{@bin_dir}",
:gem_dir => "/opt/rh/#{@scl}/root/usr/share/gems",
:ext_dir => "/opt/rh/#{@scl}/root/usr/lib64/gems" },
:local => { :bin_dir => "/opt/rh/#{@scl}/root/usr/local/#{@bin_dir}",
:gem_dir => "/opt/rh/#{@scl}/root/usr/local/share/gems",
:ext_dir => "/opt/rh/#{@scl}/root/usr/local/lib64/gems" } }
default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}",
:gem_dir => "#{@scl_root}/usr/share/gems",
:ext_dir => "#{@scl_root}/usr/lib64/gems" },
:local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}",
:gem_dir => "#{@scl_root}/usr/local/share/gems",
:ext_dir => "#{@scl_root}/usr/local/lib64/gems" } }
assert_equal default_dirs, Gem.default_dirs
end
@ -34,31 +45,46 @@ class TestDependentSCLS < Test::Unit::TestCase
#
# See rhbz#1034639
def test_paths_with_dependent_scl
prefix = '/some/prefix'
scl_name = 'ruby_x'
test_scl = 'ruby_x'
test_root = "/some/prefix/#{test_scl}/root"
ENV['X_SCLS'] = "#{@scl} #{scl_name}" # enabled scls
ENV['GEM_PATH'] = "#{prefix}/#{scl_name}/root/usr/share/gems"
default_locations = { :system => "/opt/rh/#{@scl}/root/usr",
:local => "/opt/rh/#{@scl}/root/usr/local",
:"#{scl_name}_system" => "#{prefix}/#{scl_name}/root/usr",
:"#{scl_name}_local" => "#{prefix}/#{scl_name}/root/usr/local" }
ENV['X_SCLS'] = "@SCL@ #{test_scl}" # enabled scls
ENV['GEM_PATH'] = "#{test_root}/usr/share/gems"
default_locations = { :system => "#{@scl_root}/usr",
:local => "#{@scl_root}/usr/local",
:"#{test_scl}_system" => "#{test_root}/usr",
:"#{test_scl}_local" => "#{test_root}/usr/local" }
assert_equal default_locations, Gem.default_locations
default_dirs = { :system => { :bin_dir => "/opt/rh/#{@scl}/root/usr/#{@bin_dir}",
:gem_dir => "/opt/rh/#{@scl}/root/usr/share/gems",
:ext_dir => "/opt/rh/#{@scl}/root/usr/lib64/gems" },
:local => { :bin_dir => "/opt/rh/#{@scl}/root/usr/local/#{@bin_dir}",
:gem_dir => "/opt/rh/#{@scl}/root/usr/local/share/gems",
:ext_dir => "/opt/rh/#{@scl}/root/usr/local/lib64/gems" },
:"#{scl_name}_system" => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/#{@bin_dir}",
:gem_dir => "#{prefix}/#{scl_name}/root/usr/share/gems",
:ext_dir => "#{prefix}/#{scl_name}/root/usr/lib64/gems" },
:"#{scl_name}_local" => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/local/#{@bin_dir}",
:gem_dir => "#{prefix}/#{scl_name}/root/usr/local/share/gems",
:ext_dir => "#{prefix}/#{scl_name}/root/usr/local/lib64/gems" } }
default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}",
:gem_dir => "#{@scl_root}/usr/share/gems",
:ext_dir => "#{@scl_root}/usr/lib64/gems" },
:local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}",
:gem_dir => "#{@scl_root}/usr/local/share/gems",
:ext_dir => "#{@scl_root}/usr/local/lib64/gems" },
:"#{test_scl}_system" => { :bin_dir => "#{test_root}/usr/#{@bin_dir}",
:gem_dir => "#{test_root}/usr/share/gems",
:ext_dir => "#{test_root}/usr/lib64/gems" },
:"#{test_scl}_local" => { :bin_dir => "#{test_root}/usr/local/#{@bin_dir}",
:gem_dir => "#{test_root}/usr/local/share/gems",
:ext_dir => "#{test_root}/usr/local/lib64/gems" } }
assert_equal default_dirs, Gem.default_dirs
end
def test_empty_x_scls
ENV['X_SCLS'] = nil # no enabled scls
default_locations = { :system => "#{@scl_root}/usr",
:local => "#{@scl_root}/usr/local" }
assert_equal default_locations, Gem.default_locations
default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}",
:gem_dir => "#{@scl_root}/usr/share/gems",
:ext_dir => "#{@scl_root}/usr/lib64/gems" },
:local => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}",
:gem_dir => "#{@scl_root}/usr/local/share/gems",
:ext_dir => "#{@scl_root}/usr/local/lib64/gems" } }
assert_equal default_dirs, Gem.default_dirs
end