From 5cb9711323b5dc0d36c138e64497b114fcd11535 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 17 Dec 2010 10:35:20 +0000 Subject: [PATCH] * test/mkmf/base.rb (TestMkmf::FakeLog): capture output from mkmf. * test/mkmf/test_find_executable.rb (test_find_executable): suppress meaningless diffrences for chkbuild. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 ++++++ test/mkmf/base.rb | 41 +++++++++++++++++++++++++++++++ test/mkmf/test_find_executable.rb | 1 + 3 files changed, 49 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8c890636b5..6076ef3c8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Dec 17 19:35:13 2010 Nobuyoshi Nakada + + * test/mkmf/base.rb (TestMkmf::FakeLog): capture output from mkmf. + + * test/mkmf/test_find_executable.rb (test_find_executable): + suppress meaningless diffrences for chkbuild. + Fri Dec 17 13:26:54 2010 NAKAMURA Usaku * win32/setup.mak (BASERUBY): quit with an error when BASERUBY was not diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb index 49553cf10f..d4cf80376f 100644 --- a/test/mkmf/base.rb +++ b/test/mkmf/base.rb @@ -13,6 +13,42 @@ class TestMkmf < Test::Unit::TestCase class << MKMFLOG alias to_s call end + + class Capture + def initialize + @buffer = "" + @filter = nil + @out = true + end + def clear + @buffer.clear + end + def flush + STDOUT.print @filter ? @filter.call(@buffer) : @buffer + clear + end + def reopen(io) + case io + when Capture + initialize_copy(io) + when File + @out = false + when IO + @out = true + else + @out = false + end + end + def filter(&block) + @filter = block + end + def write(s) + @buffer << s if @out + end + end + + attr_reader :stdout + def mkmflog(msg) log = proc {MKMFLOG[] << msg} class << log @@ -25,6 +61,7 @@ class TestMkmf < Test::Unit::TestCase @tmpdir = Dir.mktmpdir @curdir = Dir.pwd @mkmfobj = Object.new + @stdout = Capture.new Dir.chdir(@tmpdir) @quiet, Logging.quiet = Logging.quiet, true end @@ -37,7 +74,11 @@ class TestMkmf < Test::Unit::TestCase end def mkmf(*args, &block) + @stdout.clear + stdout, $stdout = $stdout, @stdout @mkmfobj.instance_eval(*args, &block) + ensure + $stdout = stdout end def config_value(name) diff --git a/test/mkmf/test_find_executable.rb b/test/mkmf/test_find_executable.rb index 5dca186a41..5ccec880fd 100644 --- a/test/mkmf/test_find_executable.rb +++ b/test/mkmf/test_find_executable.rb @@ -8,6 +8,7 @@ class TestMkmf ENV["PATH"] = @tmpdir name = "foobar#{$$}#{rand(1000)}" exts = mkmf {self.class::CONFIG['EXECUTABLE_EXTS']}.split + stdout.filter {|s| s.sub(name, "")} exts[0] ||= "" exts.each do |ext| full = name+ext