summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-25 05:26:38 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-25 05:26:38 +0000
commit5b37cb25ec6c4faeb0296cad1fbe48a9d7c3a56a (patch)
treeed17bcc90f6fce52cf6359344baf5dc32d84765f /test
parent12ba294b8d89227fbd6be33b9f9b7474cdf744e7 (diff)
merge revision(s) 49482,49487: [Backport #10821]
* 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/branches/ruby_2_0_0@49735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/mkmf/base.rb13
-rw-r--r--test/mkmf/test_flags.rb21
2 files changed, 33 insertions, 1 deletions
diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb
index 7df1e8961f..3ae10aa797 100644
--- a/test/mkmf/base.rb
+++ b/test/mkmf/base.rb
@@ -1,6 +1,7 @@
require 'test/unit'
require 'mkmf'
require 'tmpdir'
+require_relative '../ruby/envutil'
$extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"]
RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir'])
@@ -50,7 +51,9 @@ class TestMkmf < Test::Unit::TestCase
@buffer << s if @out
end
end
+end
+module TestMkmf::Base
attr_reader :stdout
def mkmflog(msg)
@@ -89,7 +92,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
@@ -132,3 +135,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 3bb278071a..e49d474dc9 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("nosuch.c"), TestMkmf::MKMFLOG)
+ assert(have_devel?, TestMkmf::MKMFLOG)
+ end;
+ end
+
+ def test_try_cflag_invalid_opt
+ assert_separately([], <<-'end;') #do
+ assert(!try_cflags("nosuch.c"), TestMkmf::MKMFLOG)
+ assert(have_devel?, TestMkmf::MKMFLOG)
+ end;
+ end
+
+ def test_try_cppflag_invalid_opt
+ assert_separately([], <<-'end;') #do
+ assert(!try_cppflags("nosuch.c"), TestMkmf::MKMFLOG)
+ assert(have_devel?, TestMkmf::MKMFLOG)
+ end;
+ end
end
end