[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / test / test_rbconfig.rb
blob1bbf01b9a6863c4b0f6a1386e44ea7808240f74e
1 # frozen_string_literal: false
2 require 'test/unit'
3 require 'rbconfig'
4 require 'shellwords'
6 class TestRbConfig < Test::Unit::TestCase
7   @@with_config = {}
9   Shellwords::shellwords(RbConfig::CONFIG["configure_args"]).grep(/\A--with-([^=]*)=(.*)/) do
10     @@with_config[$1.tr('_', '-')] = $2
11   end
13   def test_sitedirs
14     RbConfig::MAKEFILE_CONFIG.each do |key, val|
15       next unless /\Asite(?!arch)/ =~ key
16       next if @@with_config[key]
17       assert_match(/(?:\$\(|\/)site/, val, key)
18     end
19   end
21   def test_vendordirs
22     RbConfig::MAKEFILE_CONFIG.each do |key, val|
23       next unless /\Avendor(?!arch)/ =~ key
24       next if @@with_config[key]
25       assert_match(/(?:\$\(|\/)vendor/, val, key)
26     end
27   end
29   def test_archdirs
30     RbConfig::MAKEFILE_CONFIG.each do |key, val|
31       next unless /\A(?!site|vendor|archdir\z).*arch.*dir\z/ =~ key
32       next if @@with_config[key]
33       assert_match(/\$\(arch|\$\(rubyarchprefix\)/, val, key)
34     end
35   end
37   def test_sitearchdirs
38     bug7823 = '[ruby-dev:46964] [Bug #7823]'
39     RbConfig::MAKEFILE_CONFIG.each do |key, val|
40       next unless /\Asite.*arch.*dir\z/ =~ key
41       next if @@with_config[key]
42       assert_match(/\$\(sitearch|\$\(rubysitearchprefix\)/, val, "#{key} #{bug7823}")
43     end
44   end
46   def test_vendorarchdirs
47     bug7823 = '[ruby-dev:46964] [Bug #7823]'
48     RbConfig::MAKEFILE_CONFIG.each do |key, val|
49       next unless /\Avendor.*arch.*dir\z/ =~ key
50       next if @@with_config[key]
51       assert_match(/\$\(sitearch|\$\(rubysitearchprefix\)/, val, "#{key} #{bug7823}")
52     end
53   end
54 end