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
|
@__argv = ARGV.dup
|
||||||
@__env = ENV.to_hash # dup doesn't work on ENV
|
@__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")
|
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
|
||||||
@__stdout = $stdout.clone
|
|
||||||
@__stderr = $stderr.clone
|
|
||||||
$stdout.reopen(File::NULL)
|
$stdout.reopen(File::NULL)
|
||||||
$stderr.reopen(File::NULL)
|
$stderr.reopen(File::NULL)
|
||||||
end
|
end
|
||||||
|
|
||||||
example.run
|
example.run
|
||||||
|
rescue SystemExit => e
|
||||||
|
raise "Unexpected exit with status #{e.status}."
|
||||||
ensure
|
ensure
|
||||||
ARGV.replace(@__argv)
|
ARGV.replace(@__argv)
|
||||||
ENV.replace(@__env)
|
ENV.replace(@__env)
|
||||||
|
|
||||||
unless example.metadata.key?(:focus) || ENV.key?("VERBOSE_TESTS")
|
$stdout.reopen(@__stdout)
|
||||||
$stdout.reopen(@__stdout)
|
$stderr.reopen(@__stderr)
|
||||||
$stderr.reopen(@__stderr)
|
@__stdout.close
|
||||||
@__stdout.close
|
@__stderr.close
|
||||||
@__stderr.close
|
|
||||||
end
|
|
||||||
|
|
||||||
Formulary.clear_cache
|
Formulary.clear_cache
|
||||||
Tap.clear_cache
|
Tap.clear_cache
|
||||||
|
Loading…
x
Reference in New Issue
Block a user