Sha256: 475cadb22ebaec4b6347273d73ef9e367593ed9c13385e04452f95c76faaa783

Contents?: true

Size: 945 Bytes

Versions: 6

Compression:

Stored size: 945 Bytes

Contents

$:.unshift(File.dirname(__FILE__) + '/../lib')

require 'test/unit'
require File.dirname(__FILE__) + '/../lib/mkrf'

$debug = false

class Test::Unit::TestCase
  def silence_command_line
    yield and return if $debug
    silence_stream(STDERR) do
      silence_stream(STDOUT) do
        yield
      end
    end
  end
  
  # silence_stream taken from Rails ActiveSupport reporting.rb
  
  # Silences any stream for the duration of the block.
  #
  #   silence_stream(STDOUT) do
  #     puts 'This will never be seen'
  #   end
  #
  #   puts 'But this will'
  def silence_stream(stream)
    old_stream = stream.dup
    stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
    stream.sync = true
    yield
  ensure
    stream.reopen(old_stream)
  end
  
  protected
  
  def assert_creates_file(file)
    assert !File.exist?(file), "#{file} already exists!"
    yield
    assert File.exist?(file), "#{file} wasn't created!"
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mkrf-0.2.0 test/abstract_unit.rb
mkrf-0.2.1 test/abstract_unit.rb
mkrf-0.2.2 test/abstract_unit.rb
mkrf-0.1.1 test/abstract_unit.rb
mkrf-0.1.2 test/abstract_unit.rb
mkrf-0.2.3 test/abstract_unit.rb