Save and restore ENV around test invocations

This prevents mutations that happen in individual tests from leaking
into other tests.
This commit is contained in:
Jack Nagel 2015-01-13 12:19:56 -05:00
parent 1b74a4f5c2
commit b61528e757

View File

@ -53,6 +53,8 @@ module Homebrew
f.extend(Homebrew::Assertions)
f.extend(Debrew::Formula) if ARGV.debug?
env = ENV.to_hash
begin
# tests can also return false to indicate failure
Timeout::timeout TEST_TIMEOUT_SECONDS do
@ -64,6 +66,8 @@ module Homebrew
rescue Exception => e
ofail "#{f.name}: failed"
puts e, e.backtrace
ensure
ENV.replace(env)
end
end
end