ruby-changes:62208
From: Nobuyoshi <ko1@a...>
Date: Mon, 13 Jul 2020 18:44:56 +0900 (JST)
Subject: [ruby-changes:62208] c2a6295ec0 (master): Make the mkmf methods private in the global [Bug #16896]
https://git.ruby-lang.org/ruby.git/commit/?id=c2a6295ec0 From c2a6295ec04a191c689d22254ac1ad5d665e27ad Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 12 Jul 2020 00:09:04 +0900 Subject: Make the mkmf methods private in the global [Bug #16896] diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 3abf168..383579e 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -2822,7 +2822,12 @@ realclean: distclean https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L2822 end end -include MakeMakefile +# MakeMakefile::Global = # +m = Module.new { + include(MakeMakefile) + private(*MakeMakefile.public_instance_methods(false)) +} +include m if not $extmk and /\A(extconf|makefile).rb\z/ =~ File.basename($0) END {mkmf_failed($0)} diff --git a/test/mkmf/test_mkmf.rb b/test/mkmf/test_mkmf.rb new file mode 100644 index 0000000..adb86ec --- /dev/null +++ b/test/mkmf/test_mkmf.rb @@ -0,0 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/test/mkmf/test_mkmf.rb#L1 +# frozen_string_literal: false +require 'test/unit' +require 'mkmf' + +class TestMkmf < Test::Unit::TestCase + class TestGlobal < TestMkmf + main = TOPLEVEL_BINDING.receiver + MakeMakefile.public_instance_methods(false).each do |m| + define_method(:"test_global_#{m}") do + assert_respond_to(main, [m, true]) + assert_not_respond_to(main, [m, false]) + end + end + end +end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/