2018-06-27 12:30:05 +00:00
|
|
|
require_relative '../../spec_helper'
|
|
|
|
require 'rbconfig'
|
|
|
|
|
2019-02-21 15:38:59 +00:00
|
|
|
describe 'RbConfig::CONFIG' do
|
|
|
|
it 'values are all strings' do
|
2018-06-27 12:30:05 +00:00
|
|
|
RbConfig::CONFIG.each do |k, v|
|
|
|
|
k.should be_kind_of String
|
|
|
|
v.should be_kind_of String
|
|
|
|
end
|
|
|
|
end
|
2019-02-21 15:38:59 +00:00
|
|
|
|
2019-03-05 00:28:22 +00:00
|
|
|
# These directories have no meanings before the installation.
|
2019-03-28 14:22:29 +00:00
|
|
|
guard -> { RbConfig::TOPDIR } do
|
2019-02-23 02:22:05 +00:00
|
|
|
it "['rubylibdir'] returns the directory containing Ruby standard libraries" do
|
|
|
|
rubylibdir = RbConfig::CONFIG['rubylibdir']
|
|
|
|
File.directory?(rubylibdir).should == true
|
2019-09-29 19:13:37 +02:00
|
|
|
File.should.exist?("#{rubylibdir}/fileutils.rb")
|
2019-02-23 02:22:05 +00:00
|
|
|
end
|
2019-02-21 15:38:59 +00:00
|
|
|
|
2019-02-23 02:22:05 +00:00
|
|
|
it "['archdir'] returns the directory containing standard libraries C extensions" do
|
|
|
|
archdir = RbConfig::CONFIG['archdir']
|
|
|
|
File.directory?(archdir).should == true
|
2019-09-29 19:13:37 +02:00
|
|
|
File.should.exist?("#{archdir}/etc.#{RbConfig::CONFIG['DLEXT']}")
|
2019-02-23 02:22:05 +00:00
|
|
|
end
|
2021-06-02 14:34:07 +02:00
|
|
|
|
|
|
|
it "['sitelibdir'] is set and is part of $LOAD_PATH" do
|
|
|
|
sitelibdir = RbConfig::CONFIG['sitelibdir']
|
|
|
|
sitelibdir.should be_kind_of String
|
2021-09-07 19:01:07 +02:00
|
|
|
$LOAD_PATH.map{|path| File.realpath(path) rescue path }.should.include? sitelibdir
|
2021-06-02 14:34:07 +02:00
|
|
|
end
|
2019-02-21 15:38:59 +00:00
|
|
|
end
|
2019-11-30 21:26:52 +01: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-06-27 15:51:37 +02:00
|
|
|
if v.frozen?
|
2019-11-30 21:26:52 +01:00
|
|
|
puts "\#{k} Failure"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
puts 'Done'
|
|
|
|
RUBY
|
|
|
|
end
|
2020-03-28 00:22:51 +01:00
|
|
|
|
2021-10-05 19:41:44 +02:00
|
|
|
platform_is_not :windows do
|
|
|
|
it "['LIBRUBY'] is the same as LIBRUBY_SO if and only if ENABLE_SHARED" do
|
|
|
|
case RbConfig::CONFIG['ENABLE_SHARED']
|
|
|
|
when 'yes'
|
|
|
|
RbConfig::CONFIG['LIBRUBY'].should == RbConfig::CONFIG['LIBRUBY_SO']
|
|
|
|
when 'no'
|
|
|
|
RbConfig::CONFIG['LIBRUBY'].should_not == RbConfig::CONFIG['LIBRUBY_SO']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-02 14:34:07 +02:00
|
|
|
guard -> { RbConfig::TOPDIR } do
|
2020-03-28 22:19:21 +09:00
|
|
|
it "libdir/LIBRUBY_SO is the path to libruby and it exists if and only if ENABLE_SHARED" do
|
2020-03-29 00:14:51 +09:00
|
|
|
libdirname = RbConfig::CONFIG['LIBPATHENV'] == 'PATH' ? 'bindir' :
|
|
|
|
RbConfig::CONFIG['libdirname']
|
|
|
|
libdir = RbConfig::CONFIG[libdirname]
|
2020-03-28 22:19:21 +09:00
|
|
|
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)
|
2020-03-28 00:22:51 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-05-02 16:03:14 +02:00
|
|
|
|
|
|
|
platform_is :linux do
|
|
|
|
it "['AR'] exists and can be executed" do
|
|
|
|
ar = RbConfig::CONFIG.fetch('AR')
|
|
|
|
out = `#{ar} --version`
|
|
|
|
$?.should.success?
|
|
|
|
out.should_not be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it "['STRIP'] exists and can be executed" do
|
|
|
|
strip = RbConfig::CONFIG.fetch('STRIP')
|
2020-08-28 20:26:02 +02:00
|
|
|
copy = tmp("sh")
|
|
|
|
cp '/bin/sh', copy
|
|
|
|
begin
|
|
|
|
out = `#{strip} #{copy}`
|
|
|
|
$?.should.success?
|
|
|
|
ensure
|
|
|
|
rm_r copy
|
2020-08-21 22:25:44 +09:00
|
|
|
end
|
2020-05-02 16:03:14 +02:00
|
|
|
end
|
|
|
|
end
|
2018-06-27 12:30:05 +00:00
|
|
|
end
|
2019-04-27 18:53:23 +02: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
|