aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAlyssa Ross2017-01-21 14:57:44 +0000
committerAlyssa Ross2017-01-22 19:53:58 +0000
commit116ed3ec80b6d1b9d6178f25793cfcaaaa161308 (patch)
tree5ba702bfb1da06de3adf717f867537f667bacb52 /Library
parent6e0f1366b014b285799c9bb9c311c6345bcd666b (diff)
downloadbrew-116ed3ec80b6d1b9d6178f25793cfcaaaa161308.tar.bz2
tests: automatically restore ENV in teardown
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/audit_test.rb3
-rw-r--r--Library/Homebrew/test/commands_test.rb4
-rw-r--r--Library/Homebrew/test/diagnostic_test.rb6
-rw-r--r--Library/Homebrew/test/os/mac/diagnostic_test.rb6
-rw-r--r--Library/Homebrew/test/shell_test.rb3
-rw-r--r--Library/Homebrew/test/support/helper/test_case.rb3
-rw-r--r--Library/Homebrew/test/utils_test.rb6
7 files changed, 3 insertions, 28 deletions
diff --git a/Library/Homebrew/test/audit_test.rb b/Library/Homebrew/test/audit_test.rb
index f8d137482..75a882d69 100644
--- a/Library/Homebrew/test/audit_test.rb
+++ b/Library/Homebrew/test/audit_test.rb
@@ -361,13 +361,10 @@ class FormulaAuditorTests < Homebrew::TestCase
end
EOS
- original_value = ENV["HOMEBREW_NO_GITHUB_API"]
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
fa.audit_github_repository
assert_equal [], fa.problems
- ensure
- ENV["HOMEBREW_NO_GITHUB_API"] = original_value
end
def test_audit_caveats
diff --git a/Library/Homebrew/test/commands_test.rb b/Library/Homebrew/test/commands_test.rb
index 3d7c16e58..5f5dc9586 100644
--- a/Library/Homebrew/test/commands_test.rb
+++ b/Library/Homebrew/test/commands_test.rb
@@ -47,8 +47,6 @@ class CommandsTests < Homebrew::TestCase
end
def test_external_commands
- env = ENV.to_hash
-
mktmpdir do |dir|
%w[brew-t1 brew-t2.rb brew-t3.py].each do |file|
path = "#{dir}/#{file}"
@@ -67,8 +65,6 @@ class CommandsTests < Homebrew::TestCase
"Executable files with a non Ruby extension shoudn't be included"
refute cmds.include?("t4"), "Non-executable files shouldn't be included"
end
- ensure
- ENV.replace(env)
end
def test_internal_command_path
diff --git a/Library/Homebrew/test/diagnostic_test.rb b/Library/Homebrew/test/diagnostic_test.rb
index 2d1286827..7a1fb25f7 100644
--- a/Library/Homebrew/test/diagnostic_test.rb
+++ b/Library/Homebrew/test/diagnostic_test.rb
@@ -6,15 +6,9 @@ require "diagnostic"
class DiagnosticChecksTest < Homebrew::TestCase
def setup
super
- @env = ENV.to_hash
@checks = Homebrew::Diagnostic::Checks.new
end
- def teardown
- ENV.replace(@env)
- super
- end
-
def test_inject_file_list
assert_equal "foo:\n",
@checks.inject_file_list([], "foo:\n")
diff --git a/Library/Homebrew/test/os/mac/diagnostic_test.rb b/Library/Homebrew/test/os/mac/diagnostic_test.rb
index 284d293ca..5f467e87b 100644
--- a/Library/Homebrew/test/os/mac/diagnostic_test.rb
+++ b/Library/Homebrew/test/os/mac/diagnostic_test.rb
@@ -6,15 +6,9 @@ require "diagnostic"
class OSMacDiagnosticChecksTest < Homebrew::TestCase
def setup
super
- @env = ENV.to_hash
@checks = Homebrew::Diagnostic::Checks.new
end
- def teardown
- ENV.replace(@env)
- super
- end
-
def test_check_for_other_package_managers
MacOS.stubs(:macports_or_fink).returns ["fink"]
assert_match "You have MacPorts or Fink installed:",
diff --git a/Library/Homebrew/test/shell_test.rb b/Library/Homebrew/test/shell_test.rb
index 877acb5c8..a32d09863 100644
--- a/Library/Homebrew/test/shell_test.rb
+++ b/Library/Homebrew/test/shell_test.rb
@@ -37,7 +37,6 @@ class ShellSmokeTest < Homebrew::TestCase
end
def prepend_path_shell(shell, path, fragment)
- original_shell = ENV["SHELL"]
ENV["SHELL"] = shell
prepend_message = Utils::Shell.prepend_path_in_shell_profile(path)
@@ -45,8 +44,6 @@ class ShellSmokeTest < Homebrew::TestCase
prepend_message.start_with?(fragment),
"#{shell}: expected #{prepend_message} to match #{fragment}"
)
-
- ENV["SHELL"] = original_shell
end
def test_prepend_path_in_shell_profile
diff --git a/Library/Homebrew/test/support/helper/test_case.rb b/Library/Homebrew/test/support/helper/test_case.rb
index 53d4e7031..c4c7f8727 100644
--- a/Library/Homebrew/test/support/helper/test_case.rb
+++ b/Library/Homebrew/test/support/helper/test_case.rb
@@ -16,11 +16,14 @@ module Homebrew
def setup
super
+
@__argv = ARGV.dup
+ @__env = copy_env # Call #to_hash to duplicate ENV
end
def teardown
ARGV.replace(@__argv)
+ restore_env @__env
Tab.clear_cache
diff --git a/Library/Homebrew/test/utils_test.rb b/Library/Homebrew/test/utils_test.rb
index 7099e332c..7ff4e192a 100644
--- a/Library/Homebrew/test/utils_test.rb
+++ b/Library/Homebrew/test/utils_test.rb
@@ -7,12 +7,6 @@ class UtilTests < Homebrew::TestCase
def setup
super
@dir = Pathname.new(mktmpdir)
- @env = ENV.to_hash
- end
-
- def teardown
- ENV.replace @env
- super
end
def test_ofail