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:
		
							parent
							
								
									da60d77e08
								
							
						
					
					
						commit
						f148354cb2
					
				| @ -42,7 +42,11 @@ module Gem | |||||||
|     # Get enabled SCLs in order of (most) dependent SCL to base SCL |     # Get enabled SCLs in order of (most) dependent SCL to base SCL | ||||||
| 
 | 
 | ||||||
|     def x_scls |     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 |     end | ||||||
|     private :x_scls |     private :x_scls | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								ruby.spec
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ruby.spec
									
									
									
									
									
								
							| @ -23,7 +23,7 @@ | |||||||
| %global ruby_archive %{ruby_archive}-%{?milestone}%{?!milestone:%{?revision:r%{revision}}} | %global ruby_archive %{ruby_archive}-%{?milestone}%{?!milestone:%{?revision:r%{revision}}} | ||||||
| %endif | %endif | ||||||
| 
 | 
 | ||||||
| %global release 63 | %global release 64 | ||||||
| %{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} | %{!?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 | # 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 | %check | ||||||
| # Ruby software collection tests | # Ruby software collection tests | ||||||
| %{?scl:scl enable %scl - << \EOF | %{?scl:scl enable %scl - << \EOF | ||||||
|  | set -e | ||||||
| mkdir -p ./lib/rubygems/defaults | mkdir -p ./lib/rubygems/defaults | ||||||
| cp %{SOURCE1} ./lib/rubygems/defaults | cp %{SOURCE1} ./lib/rubygems/defaults | ||||||
| make test-all TESTS="%{SOURCE14}" || exit 1 | sed 's/@SCL@/%{scl}/' %{SOURCE14} > ./%{basename:%{SOURCE14}} | ||||||
| rm -rf ./lib/rubygems/defaults | make test-all TESTS="%{basename:%{SOURCE14}}" | ||||||
|  | rm -rf ./lib/rubygems/defaults ./%{basename:%{SOURCE14}} | ||||||
| EOF} | EOF} | ||||||
| 
 | 
 | ||||||
| # Check RubyGems version correctness. | # Check RubyGems version correctness. | ||||||
| @ -963,7 +965,11 @@ make check TESTS="-v $DISABLE_TESTS" | |||||||
| %{ruby_libdir}/tkextlib | %{ruby_libdir}/tkextlib | ||||||
| 
 | 
 | ||||||
| %changelog | %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 | - Support in no_proxy for domain names with whitespaces and leading dots | ||||||
|   Resolves: rhbz#1384810 |   Resolves: rhbz#1384810 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -6,25 +6,36 @@ require 'rubygems/defaults/operating_system' | |||||||
| class TestDependentSCLS < Test::Unit::TestCase | class TestDependentSCLS < Test::Unit::TestCase | ||||||
| 
 | 
 | ||||||
|   def setup |   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") |     # TODO: Different bin dir during build ("/builddir/build/BUILD/ruby-2.0.0-p247") | ||||||
|     @bin_dir = Gem::ConfigMap[:bindir].split(File::SEPARATOR).last |     @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 |   end | ||||||
| 
 | 
 | ||||||
|   def test_default_paths |   def test_default_paths | ||||||
|     default_locations = { :system => "/opt/rh/#{@scl}/root/usr", |     ENV['X_SCLS'] = '@SCL@' # enabled scls | ||||||
|                           :local  => "/opt/rh/#{@scl}/root/usr/local" } | 
 | ||||||
|  |     default_locations = { :system => "#{@scl_root}/usr", | ||||||
|  |                           :local  => "#{@scl_root}/usr/local" } | ||||||
|     assert_equal default_locations, Gem.default_locations |     assert_equal default_locations, Gem.default_locations | ||||||
| 
 | 
 | ||||||
|     default_dirs = { :system => { :bin_dir => "/opt/rh/#{@scl}/root/usr/#{@bin_dir}", |     default_dirs = { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", | ||||||
|                                   :gem_dir => "/opt/rh/#{@scl}/root/usr/share/gems", |                                   :gem_dir => "#{@scl_root}/usr/share/gems", | ||||||
|                                   :ext_dir => "/opt/rh/#{@scl}/root/usr/lib64/gems" }, |                                   :ext_dir => "#{@scl_root}/usr/lib64/gems" }, | ||||||
|                      :local  => { :bin_dir => "/opt/rh/#{@scl}/root/usr/local/#{@bin_dir}", |                      :local  => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", | ||||||
|                                   :gem_dir => "/opt/rh/#{@scl}/root/usr/local/share/gems", |                                   :gem_dir => "#{@scl_root}/usr/local/share/gems", | ||||||
|                                   :ext_dir => "/opt/rh/#{@scl}/root/usr/local/lib64/gems" } } |                                   :ext_dir => "#{@scl_root}/usr/local/lib64/gems" } } | ||||||
|     assert_equal default_dirs, Gem.default_dirs |     assert_equal default_dirs, Gem.default_dirs | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
| @ -34,31 +45,46 @@ class TestDependentSCLS < Test::Unit::TestCase | |||||||
|   # |   # | ||||||
|   # See rhbz#1034639 |   # See rhbz#1034639 | ||||||
|   def test_paths_with_dependent_scl |   def test_paths_with_dependent_scl | ||||||
|     prefix = '/some/prefix' |     test_scl = 'ruby_x' | ||||||
|     scl_name = 'ruby_x' |     test_root = "/some/prefix/#{test_scl}/root" | ||||||
| 
 | 
 | ||||||
|     ENV['X_SCLS'] = "#{@scl} #{scl_name}" # enabled scls |     ENV['X_SCLS'] = "@SCL@ #{test_scl}" # enabled scls | ||||||
|     ENV['GEM_PATH'] = "#{prefix}/#{scl_name}/root/usr/share/gems" |     ENV['GEM_PATH'] = "#{test_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" } |  | ||||||
| 
 | 
 | ||||||
|  |     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 |     assert_equal default_locations, Gem.default_locations | ||||||
| 
 | 
 | ||||||
|     default_dirs =  { :system => { :bin_dir => "/opt/rh/#{@scl}/root/usr/#{@bin_dir}", |     default_dirs =  { :system => { :bin_dir => "#{@scl_root}/usr/#{@bin_dir}", | ||||||
|                                    :gem_dir => "/opt/rh/#{@scl}/root/usr/share/gems", |                                    :gem_dir => "#{@scl_root}/usr/share/gems", | ||||||
|                                    :ext_dir => "/opt/rh/#{@scl}/root/usr/lib64/gems" }, |                                    :ext_dir => "#{@scl_root}/usr/lib64/gems" }, | ||||||
|                       :local  => { :bin_dir => "/opt/rh/#{@scl}/root/usr/local/#{@bin_dir}", |                       :local  => { :bin_dir => "#{@scl_root}/usr/local/#{@bin_dir}", | ||||||
|                                    :gem_dir => "/opt/rh/#{@scl}/root/usr/local/share/gems", |                                    :gem_dir => "#{@scl_root}/usr/local/share/gems", | ||||||
|                                    :ext_dir => "/opt/rh/#{@scl}/root/usr/local/lib64/gems" }, |                                    :ext_dir => "#{@scl_root}/usr/local/lib64/gems" }, | ||||||
|                       :"#{scl_name}_system" => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/#{@bin_dir}", |                       :"#{test_scl}_system" => { :bin_dir => "#{test_root}/usr/#{@bin_dir}", | ||||||
|                                                  :gem_dir => "#{prefix}/#{scl_name}/root/usr/share/gems", |                                                  :gem_dir => "#{test_root}/usr/share/gems", | ||||||
|                                                  :ext_dir => "#{prefix}/#{scl_name}/root/usr/lib64/gems" }, |                                                  :ext_dir => "#{test_root}/usr/lib64/gems" }, | ||||||
|                       :"#{scl_name}_local"  => { :bin_dir => "#{prefix}/#{scl_name}/root/usr/local/#{@bin_dir}", |                       :"#{test_scl}_local"  => { :bin_dir => "#{test_root}/usr/local/#{@bin_dir}", | ||||||
|                                                  :gem_dir => "#{prefix}/#{scl_name}/root/usr/local/share/gems", |                                                  :gem_dir => "#{test_root}/usr/local/share/gems", | ||||||
|                                                  :ext_dir => "#{prefix}/#{scl_name}/root/usr/local/lib64/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 |     assert_equal default_dirs, Gem.default_dirs | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user