summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-03 08:15:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-03 08:15:47 +0000
commitaf5b7053f17b61681b7c492800cc8bf347de1cdd (patch)
tree40bbedd3bfb68d3ec12820ddeac7b793a95fb905
parent26127361dd2100afe73bc5b2304735f82716ce3c (diff)
mkmf.rb: avoid interference
* lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of interference by modifying global variables in have_devel? method. [ruby-core:67962] [Bug #10821] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/mkmf.rb12
-rw-r--r--test/mkmf/base.rb12
-rw-r--r--test/mkmf/test_flags.rb21
4 files changed, 41 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index f0ce571..2504250 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Feb 3 17:15:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): get rid of
+ interference by modifying global variables in have_devel? method.
+ [ruby-core:67962] [Bug #10821]
+
Tue Feb 3 15:23:58 2015 Shugo Maeda <shugo@ruby-lang.org>
* vm_method.c (remove_method): When remove refined
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index e8750e4..67af386 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -610,9 +610,7 @@ MSG
end
def try_cppflags(flags)
- with_cppflags(flags) do
- try_header("int main() {return 0;}")
- end
+ try_header(MAIN_DOES_NOTHING, flags)
end
def with_cflags(flags)
@@ -624,9 +622,7 @@ MSG
end
def try_cflags(flags)
- with_cflags(flags) do
- try_compile("int main() {return 0;}")
- end
+ try_compile(MAIN_DOES_NOTHING, flags)
end
def with_ldflags(flags)
@@ -638,9 +634,7 @@ MSG
end
def try_ldflags(flags)
- with_ldflags(flags) do
- try_link("int main() {return 0;}")
- end
+ try_link(MAIN_DOES_NOTHING, flags)
end
def try_static_assert(expr, headers = nil, opt = "", &b)
diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb
index ab1a0f0..ea6a9d8 100644
--- a/test/mkmf/base.rb
+++ b/test/mkmf/base.rb
@@ -49,7 +49,9 @@ class TestMkmf < Test::Unit::TestCase
@buffer << s if @out
end
end
+end
+module TestMkmf::Base
attr_reader :stdout
def mkmflog(msg)
@@ -84,7 +86,7 @@ class TestMkmf < Test::Unit::TestCase
@tmpdir = Dir.mktmpdir
@curdir = Dir.pwd
@mkmfobj = Object.new
- @stdout = Capture.new
+ @stdout = TestMkmf::Capture.new
Dir.chdir(@tmpdir)
@quiet, Logging.quiet = Logging.quiet, true
init_mkmf
@@ -127,3 +129,11 @@ class TestMkmf < Test::Unit::TestCase
nil
end
end
+
+class TestMkmf
+ include TestMkmf::Base
+
+ def assert_separately(args, src, *rest)
+ super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\n#{src}", *rest)
+ end
+end
diff --git a/test/mkmf/test_flags.rb b/test/mkmf/test_flags.rb
index 3bb2780..4e0d5f6 100644
--- a/test/mkmf/test_flags.rb
+++ b/test/mkmf/test_flags.rb
@@ -31,5 +31,26 @@ class TestMkmf
$warnflags = warnflags
$extmk = val
end
+
+ def test_try_ldflag_invalid_opt
+ assert_separately([], <<-'end;') #do
+ assert(!try_ldflags("----------"))
+ assert(have_devel?, TestMkmf::MKMFLOG)
+ end;
+ end
+
+ def test_try_cflag_invalid_opt
+ assert_separately([], <<-'end;') #do
+ assert(!try_cflags("----------"))
+ assert(have_devel?, TestMkmf::MKMFLOG)
+ end;
+ end
+
+ def test_try_cppflag_invalid_opt
+ assert_separately([], <<-'end;') #do
+ assert(!try_cppflags("----------"))
+ assert(have_devel?, TestMkmf::MKMFLOG)
+ end;
+ end
end
end