aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2015-01-13 12:19:56 -0500
committerJack Nagel2015-01-13 12:19:56 -0500
commitb61528e757feb53f5b1d4f05706a55364bd3f265 (patch)
tree8f46410ec5a2a6ebe5a049009961bcbf30130013 /Library
parent1b74a4f5c2c1b8da70b7df242140d6a53ee8abcf (diff)
downloadbrew-b61528e757feb53f5b1d4f05706a55364bd3f265.tar.bz2
Save and restore ENV around test invocations
This prevents mutations that happen in individual tests from leaking into other tests.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/cmd/test.rb
index 630450744..139cebfed 100644
--- a/Library/Homebrew/cmd/test.rb
+++ b/Library/Homebrew/cmd/test.rb
@@ -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