tests: automatically restore ENV in teardown
This commit is contained in:
parent
6e0f1366b0
commit
116ed3ec80
@ -361,13 +361,10 @@ class FormulaAuditorTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
original_value = ENV["HOMEBREW_NO_GITHUB_API"]
|
|
||||||
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
|
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
|
||||||
|
|
||||||
fa.audit_github_repository
|
fa.audit_github_repository
|
||||||
assert_equal [], fa.problems
|
assert_equal [], fa.problems
|
||||||
ensure
|
|
||||||
ENV["HOMEBREW_NO_GITHUB_API"] = original_value
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_audit_caveats
|
def test_audit_caveats
|
||||||
|
|||||||
@ -47,8 +47,6 @@ class CommandsTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_external_commands
|
def test_external_commands
|
||||||
env = ENV.to_hash
|
|
||||||
|
|
||||||
mktmpdir do |dir|
|
mktmpdir do |dir|
|
||||||
%w[brew-t1 brew-t2.rb brew-t3.py].each do |file|
|
%w[brew-t1 brew-t2.rb brew-t3.py].each do |file|
|
||||||
path = "#{dir}/#{file}"
|
path = "#{dir}/#{file}"
|
||||||
@ -67,8 +65,6 @@ class CommandsTests < Homebrew::TestCase
|
|||||||
"Executable files with a non Ruby extension shoudn't be included"
|
"Executable files with a non Ruby extension shoudn't be included"
|
||||||
refute cmds.include?("t4"), "Non-executable files shouldn't be included"
|
refute cmds.include?("t4"), "Non-executable files shouldn't be included"
|
||||||
end
|
end
|
||||||
ensure
|
|
||||||
ENV.replace(env)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_internal_command_path
|
def test_internal_command_path
|
||||||
|
|||||||
@ -6,15 +6,9 @@ require "diagnostic"
|
|||||||
class DiagnosticChecksTest < Homebrew::TestCase
|
class DiagnosticChecksTest < Homebrew::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@env = ENV.to_hash
|
|
||||||
@checks = Homebrew::Diagnostic::Checks.new
|
@checks = Homebrew::Diagnostic::Checks.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
|
||||||
ENV.replace(@env)
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_inject_file_list
|
def test_inject_file_list
|
||||||
assert_equal "foo:\n",
|
assert_equal "foo:\n",
|
||||||
@checks.inject_file_list([], "foo:\n")
|
@checks.inject_file_list([], "foo:\n")
|
||||||
|
|||||||
@ -6,15 +6,9 @@ require "diagnostic"
|
|||||||
class OSMacDiagnosticChecksTest < Homebrew::TestCase
|
class OSMacDiagnosticChecksTest < Homebrew::TestCase
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@env = ENV.to_hash
|
|
||||||
@checks = Homebrew::Diagnostic::Checks.new
|
@checks = Homebrew::Diagnostic::Checks.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
|
||||||
ENV.replace(@env)
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_check_for_other_package_managers
|
def test_check_for_other_package_managers
|
||||||
MacOS.stubs(:macports_or_fink).returns ["fink"]
|
MacOS.stubs(:macports_or_fink).returns ["fink"]
|
||||||
assert_match "You have MacPorts or Fink installed:",
|
assert_match "You have MacPorts or Fink installed:",
|
||||||
|
|||||||
@ -37,7 +37,6 @@ class ShellSmokeTest < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def prepend_path_shell(shell, path, fragment)
|
def prepend_path_shell(shell, path, fragment)
|
||||||
original_shell = ENV["SHELL"]
|
|
||||||
ENV["SHELL"] = shell
|
ENV["SHELL"] = shell
|
||||||
|
|
||||||
prepend_message = Utils::Shell.prepend_path_in_shell_profile(path)
|
prepend_message = Utils::Shell.prepend_path_in_shell_profile(path)
|
||||||
@ -45,8 +44,6 @@ class ShellSmokeTest < Homebrew::TestCase
|
|||||||
prepend_message.start_with?(fragment),
|
prepend_message.start_with?(fragment),
|
||||||
"#{shell}: expected #{prepend_message} to match #{fragment}"
|
"#{shell}: expected #{prepend_message} to match #{fragment}"
|
||||||
)
|
)
|
||||||
|
|
||||||
ENV["SHELL"] = original_shell
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_prepend_path_in_shell_profile
|
def test_prepend_path_in_shell_profile
|
||||||
|
|||||||
@ -16,11 +16,14 @@ module Homebrew
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
@__argv = ARGV.dup
|
@__argv = ARGV.dup
|
||||||
|
@__env = copy_env # Call #to_hash to duplicate ENV
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
ARGV.replace(@__argv)
|
ARGV.replace(@__argv)
|
||||||
|
restore_env @__env
|
||||||
|
|
||||||
Tab.clear_cache
|
Tab.clear_cache
|
||||||
|
|
||||||
|
|||||||
@ -7,12 +7,6 @@ class UtilTests < Homebrew::TestCase
|
|||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@dir = Pathname.new(mktmpdir)
|
@dir = Pathname.new(mktmpdir)
|
||||||
@env = ENV.to_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
ENV.replace @env
|
|
||||||
super
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ofail
|
def test_ofail
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user