1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/mkmf/base.rb
nobu 61d197a62d * test/mkmf/base.rb (TestMkmf#config_value): extract macro value from
config.h.
* test/mkmf/test_sizeof.rb (TestMkmf::TestSizeof#test_sizeof_builtin),
 (TestMkmf::TestSizeof#test_sizeof_struct): more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-10 09:12:33 +00:00

50 lines
1.1 KiB
Ruby

require 'test/unit'
require 'mkmf'
require 'tmpdir'
$extout = '$(topdir)/'+RbConfig::CONFIG["EXTOUT"]
RbConfig::CONFIG['topdir'] = CONFIG['topdir'] = File.expand_path(CONFIG['topdir'])
RbConfig::CONFIG["extout"] = CONFIG["extout"] = $extout
$INCFLAGS << " -I."
$extout_prefix = "$(extout)$(target_prefix)/"
class TestMkmf < Test::Unit::TestCase
MKMFLOG = proc {File.read("mkmf.log") rescue ""}
class << MKMFLOG
alias to_s call
end
def mkmflog(msg)
log = proc {MKMFLOG[] << msg}
class << log
alias to_s call
end
log
end
def setup
@tmpdir = Dir.mktmpdir
@curdir = Dir.pwd
@mkmfobj = Object.new
Dir.chdir(@tmpdir)
@quiet, Logging.quiet = Logging.quiet, true
end
def teardown
Logging.quiet = @quiet
Logging.log_close
Dir.chdir(@curdir)
FileUtils.rm_rf(@tmpdir)
end
def mkmf(*args, &block)
@mkmfobj.instance_eval(*args, &block)
end
def config_value(name)
create_tmpsrc("---config-value=#{name}")
xpopen(cpp_command('')) do |f|
f.grep(/^---config-value=(.*)/) {return $1}
end
nil
end
end