tests: add utility method to quell output
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
472322af24
commit
af7bf47e31
@ -23,22 +23,12 @@ end
|
|||||||
|
|
||||||
class ConfigureTests < Test::Unit::TestCase
|
class ConfigureTests < Test::Unit::TestCase
|
||||||
def test_detect_failed_configure
|
def test_detect_failed_configure
|
||||||
tmperr = $stderr
|
|
||||||
tmpout = $stdout
|
|
||||||
require 'stringio'
|
|
||||||
$stderr = StringIO.new
|
|
||||||
$stdout = StringIO.new
|
|
||||||
|
|
||||||
f = ConfigureFails.new
|
f = ConfigureFails.new
|
||||||
|
|
||||||
begin
|
begin
|
||||||
f.brew { f.install }
|
shutup { f.brew { f.install } }
|
||||||
rescue BuildError => e
|
rescue BuildError => e
|
||||||
assert e.was_running_configure?
|
assert e.was_running_configure?
|
||||||
end
|
end
|
||||||
|
|
||||||
$stderr = tmperr
|
|
||||||
$stdout = tmpout
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class PatchingTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_single_patch
|
def test_single_patch
|
||||||
nostdout do
|
shutup do
|
||||||
DefaultPatchBall.new('test_patch').brew do
|
DefaultPatchBall.new('test_patch').brew do
|
||||||
s = read_file 'libexec/NOOP'
|
s = read_file 'libexec/NOOP'
|
||||||
assert !s.include?("NOOP"), "File was unpatched."
|
assert !s.include?("NOOP"), "File was unpatched."
|
||||||
@ -49,7 +49,7 @@ class PatchingTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_patch_list
|
def test_patch_list
|
||||||
nostdout do
|
shutup do
|
||||||
ListPatchBall.new('test_patch_list').brew do
|
ListPatchBall.new('test_patch_list').brew do
|
||||||
s = read_file 'libexec/NOOP'
|
s = read_file 'libexec/NOOP'
|
||||||
assert !s.include?("NOOP"), "File was unpatched."
|
assert !s.include?("NOOP"), "File was unpatched."
|
||||||
@ -59,7 +59,7 @@ class PatchingTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_p0_patch
|
def test_p0_patch
|
||||||
nostdout do
|
shutup do
|
||||||
P0PatchBall.new('test_p0_patch').brew do
|
P0PatchBall.new('test_p0_patch').brew do
|
||||||
s = read_file 'libexec/NOOP'
|
s = read_file 'libexec/NOOP'
|
||||||
assert !s.include?("NOOP"), "File was unpatched."
|
assert !s.include?("NOOP"), "File was unpatched."
|
||||||
@ -69,7 +69,7 @@ class PatchingTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_p1_patch
|
def test_p1_patch
|
||||||
nostdout do
|
shutup do
|
||||||
P1PatchBall.new('test_p1_patch').brew do
|
P1PatchBall.new('test_p1_patch').brew do
|
||||||
s = read_file 'libexec/NOOP'
|
s = read_file 'libexec/NOOP'
|
||||||
assert !s.include?("NOOP"), "File was unpatched."
|
assert !s.include?("NOOP"), "File was unpatched."
|
||||||
|
|||||||
@ -35,4 +35,21 @@ module Homebrew extend self
|
|||||||
include FileUtils
|
include FileUtils
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def shutup
|
||||||
|
if ARGV.verbose?
|
||||||
|
yield
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
tmperr = $stderr.clone
|
||||||
|
tmpout = $stdout.clone
|
||||||
|
$stderr.reopen '/dev/null', 'w'
|
||||||
|
$stdout.reopen '/dev/null', 'w'
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
$stderr.reopen tmperr
|
||||||
|
$stdout.reopen tmpout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
require 'test/unit' # must be after at_exit
|
require 'test/unit' # must be after at_exit
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user