summaryrefslogtreecommitdiff
path: root/test/mkmf
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-17 10:35:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-17 10:35:20 +0000
commit5cb9711323b5dc0d36c138e64497b114fcd11535 (patch)
tree15d9e38873a8a69ab1a594739a77f4c816829c3b /test/mkmf
parent96064d18895b2c2569f99d02a27181d99316c0b1 (diff)
* 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
Diffstat (limited to 'test/mkmf')
-rw-r--r--test/mkmf/base.rb41
-rw-r--r--test/mkmf/test_find_executable.rb1
2 files changed, 42 insertions, 0 deletions
diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb
index 49553cf..d4cf803 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 5dca186..5ccec88 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, "<executable>")}
exts[0] ||= ""
exts.each do |ext|
full = name+ext