2018-06-27 08:30:05 -04:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require 'rbconfig'
|
|
|
|
|
2019-02-21 10:38:59 -05:00
|
|
|
describe 'RbConfig::CONFIG' do
|
|
|
|
it 'values are all strings' do
|
2018-06-27 08:30:05 -04:00
|
|
|
RbConfig::CONFIG.each do |k, v|
|
|
|
|
k.should be_kind_of String
|
|
|
|
v.should be_kind_of String
|
|
|
|
end
|
|
|
|
end
|
2019-02-21 10:38:59 -05:00
|
|
|
|
2019-03-04 19:28:22 -05:00
|
|
|
# These directories have no meanings before the installation.
|
2019-03-28 10:22:29 -04:00
|
|
|
guard -> { RbConfig::TOPDIR } do
|
2019-02-22 21:22:05 -05:00
|
|
|
it "['rubylibdir'] returns the directory containing Ruby standard libraries" do
|
|
|
|
rubylibdir = RbConfig::CONFIG['rubylibdir']
|
|
|
|
File.directory?(rubylibdir).should == true
|
2019-09-29 13:13:37 -04:00
|
|
|
File.should.exist?("#{rubylibdir}/fileutils.rb")
|
2019-02-22 21:22:05 -05:00
|
|
|
end
|
2019-02-21 10:38:59 -05:00
|
|
|
|
2019-02-22 21:22:05 -05:00
|
|
|
it "['archdir'] returns the directory containing standard libraries C extensions" do
|
|
|
|
archdir = RbConfig::CONFIG['archdir']
|
|
|
|
File.directory?(archdir).should == true
|
2019-09-29 13:13:37 -04:00
|
|
|
File.should.exist?("#{archdir}/etc.#{RbConfig::CONFIG['DLEXT']}")
|
2019-02-22 21:22:05 -05:00
|
|
|
end
|
2019-02-21 10:38:59 -05:00
|
|
|
end
|
2019-11-30 15:26:52 -05:00
|
|
|
|
|
|
|
it "contains no frozen strings even with --enable-frozen-string-literal" do
|
|
|
|
ruby_exe(<<-RUBY, options: '--enable-frozen-string-literal').should == "Done\n"
|
|
|
|
require 'rbconfig'
|
|
|
|
RbConfig::CONFIG.each do |k, v|
|
2020-03-27 19:22:51 -04:00
|
|
|
# SDKROOT excluded here to workaround the issue: https://bugs.ruby-lang.org/issues/16738
|
|
|
|
if v.frozen? && k != 'SDKROOT'
|
2019-11-30 15:26:52 -05:00
|
|
|
puts "\#{k} Failure"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
puts 'Done'
|
|
|
|
RUBY
|
|
|
|
end
|
2020-03-27 19:22:51 -04:00
|
|
|
|
2020-03-28 06:31:11 -04:00
|
|
|
platform_is_not :windows do
|
|
|
|
guard -> {RbConfig::TOPDIR} do
|
|
|
|
it "libdir/LIBRUBY_SO is the path to libruby and it exists if and only if ENABLE_SHARED" do
|
|
|
|
libdir = RbConfig::CONFIG[RbConfig::CONFIG['libdirname'] || 'libdir']
|
|
|
|
libruby_so = "#{libdir}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
|
|
|
|
case RbConfig::CONFIG['ENABLE_SHARED']
|
|
|
|
when 'yes'
|
|
|
|
File.should.exist?(libruby_so)
|
|
|
|
when 'no'
|
|
|
|
File.should_not.exist?(libruby_so)
|
|
|
|
end
|
2020-03-27 19:22:51 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-06-27 08:30:05 -04:00
|
|
|
end
|
2019-04-27 12:53:23 -04:00
|
|
|
|
|
|
|
describe "RbConfig::TOPDIR" do
|
|
|
|
it "either returns nil (if not installed) or the prefix" do
|
|
|
|
if RbConfig::TOPDIR
|
|
|
|
RbConfig::TOPDIR.should == RbConfig::CONFIG["prefix"]
|
|
|
|
else
|
|
|
|
RbConfig::TOPDIR.should == nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|