aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/support/helper/shutup.rb
blob: fa5f08d31e8985374928b6b893b6eec641191837 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Test
  module Helper
    module Shutup
      def shutup
        if ENV.key?("VERBOSE_TESTS")
          yield
        else
          begin
            tmperr = $stderr.clone
            tmpout = $stdout.clone
            $stderr.reopen("/dev/null")
            $stdout.reopen("/dev/null")
            yield
          ensure
            $stderr.reopen(tmperr)
            $stdout.reopen(tmpout)
            tmperr.close
            tmpout.close
          end
        end
      end
    end
  end
end