mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Improve spec helper.
This commit is contained in:
parent
740e0242fa
commit
a6be0e62af
@ -173,24 +173,25 @@ RSpec.configure do |config|
|
||||
@__argv = ARGV.dup
|
||||
@__env = ENV.to_hash # dup doesn't work on ENV
|
||||
|
||||
@__stdout = $stdout.clone
|
||||
@__stderr = $stderr.clone
|
||||
|
||||
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
|
||||
@__stdout = $stdout.clone
|
||||
@__stderr = $stderr.clone
|
||||
$stdout.reopen(File::NULL)
|
||||
$stderr.reopen(File::NULL)
|
||||
end
|
||||
|
||||
example.run
|
||||
rescue SystemExit => e
|
||||
raise "Unexpected exit with status #{e.status}."
|
||||
ensure
|
||||
ARGV.replace(@__argv)
|
||||
ENV.replace(@__env)
|
||||
|
||||
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
|
||||
$stdout.reopen(@__stdout)
|
||||
$stderr.reopen(@__stderr)
|
||||
@__stdout.close
|
||||
@__stderr.close
|
||||
end
|
||||
$stdout.reopen(@__stdout)
|
||||
$stderr.reopen(@__stderr)
|
||||
@__stdout.close
|
||||
@__stderr.close
|
||||
|
||||
Formulary.clear_cache
|
||||
Tap.clear_cache
|
||||
|
Loading…
x
Reference in New Issue
Block a user