diff options
Diffstat (limited to 'test/mkmf/test_config.rb')
-rw-r--r-- | test/mkmf/test_config.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/mkmf/test_config.rb b/test/mkmf/test_config.rb index 7211c61d53..0d2cb3751c 100644 --- a/test/mkmf/test_config.rb +++ b/test/mkmf/test_config.rb @@ -1,5 +1,6 @@ # frozen_string_literal: false require_relative 'base' +require 'tempfile' class TestMkmfConfig < TestMkmf def test_dir_config @@ -27,4 +28,30 @@ class TestMkmfConfig < TestMkmf assert_equal(false, with_config("foo")) end; end + + def test_with_target_rbconfig + Tempfile.create(%w"rbconfig .rb", ".") do |tmp| + tmp.puts <<~'end;' + module RbConfig + CONFIG = {} + MAKEFILE_CONFIG = {} + + def self.fire_update!(key, value); end + def self.expand(val, config = CONFIG); val; end + end; + ::RbConfig::CONFIG.each do |k, v| + tmp.puts " CONFIG[#{k.dump}] = #{v.dump}" + end + ::RbConfig::MAKEFILE_CONFIG.each do |k, v| + tmp.puts " MAKEFILE_CONFIG[#{k.dump}] = #{v.dump}" + end + tmp.puts " CONFIG['testing-only'] = 'ok'" + tmp.puts "end" + tmp.close + assert_separately([], ["--target-rbconfig=#{tmp.path}"], <<-'end;') + assert_equal("ok", MakeMakefile::RbConfig::CONFIG["testing-only"]) + assert_not_equal(::RbConfig, MakeMakefile::RbConfig) + end; + end + end end |