tests: remove with_git_env method

A common git environment is now used in all tests, so this is no longer
required.
This commit is contained in:
Alyssa Ross 2017-01-22 20:54:37 +00:00
parent b53ce62ffb
commit 19e61355b3
6 changed files with 44 additions and 69 deletions

View File

@ -34,6 +34,7 @@ module Homebrew
%w[AUTHOR COMMITTER].each do |role| %w[AUTHOR COMMITTER].each do |role|
ENV["GIT_#{role}_NAME"] = "brew tests" ENV["GIT_#{role}_NAME"] = "brew tests"
ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
ENV["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
end end
Homebrew.install_gem_setup_path! "bundler" Homebrew.install_gem_setup_path! "bundler"

View File

@ -158,7 +158,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
end end
def setup_git_repo def setup_git_repo
using_git_env do
@cached_location.cd do @cached_location.cd do
shutup do shutup do
system "git", "init" system "git", "init"
@ -168,7 +167,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
git_commit_all git_commit_all
end end
end end
end
def test_github_git_download_strategy_user_repo def test_github_git_download_strategy_user_repo
resource = ResourceDouble.new("https://github.com/homebrew/brew.git") resource = ResourceDouble.new("https://github.com/homebrew/brew.git")
@ -185,12 +183,10 @@ class GitDownloadStrategyTests < Homebrew::TestCase
def test_last_commit def test_last_commit
setup_git_repo setup_git_repo
using_git_env do
@cached_location.cd do @cached_location.cd do
touch "LICENSE" touch "LICENSE"
git_commit_all git_commit_all
end end
end
assert_equal "f68266e", @strategy.last_commit assert_equal "f68266e", @strategy.last_commit
end end
@ -202,7 +198,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
resource.instance_variable_set(:@version, Version.create("HEAD")) resource.instance_variable_set(:@version, Version.create("HEAD"))
@strategy = GitDownloadStrategy.new("baz", resource) @strategy = GitDownloadStrategy.new("baz", resource)
using_git_env do
remote_repo.cd do remote_repo.cd do
shutup do shutup do
system "git", "init" system "git", "init"
@ -213,7 +208,6 @@ class GitDownloadStrategyTests < Homebrew::TestCase
touch "LICENSE" touch "LICENSE"
git_commit_all git_commit_all
end end
end
@strategy.shutup! @strategy.shutup!
assert_equal "f68266e", @strategy.fetch_last_commit assert_equal "f68266e", @strategy.fetch_last_commit

View File

@ -533,7 +533,6 @@ class FormulaTests < Homebrew::TestCase
cached_location = f.head.downloader.cached_location cached_location = f.head.downloader.cached_location
cached_location.mkpath cached_location.mkpath
using_git_env do
cached_location.cd do cached_location.cd do
FileUtils.touch "LICENSE" FileUtils.touch "LICENSE"
shutup do shutup do
@ -542,7 +541,6 @@ class FormulaTests < Homebrew::TestCase
system "git", "commit", "-m", "Initial commit" system "git", "commit", "-m", "Initial commit"
end end
end end
end
f.update_head_version f.update_head_version
assert_equal Version.create("HEAD-5658946"), f.head.version assert_equal Version.create("HEAD-5658946"), f.head.version
@ -1105,7 +1103,6 @@ class OutdatedVersionsTests < Homebrew::TestCase
head "file://#{testball_repo}", using: :git head "file://#{testball_repo}", using: :git
end end
using_git_env do
testball_repo.cd do testball_repo.cd do
FileUtils.touch "LICENSE" FileUtils.touch "LICENSE"
shutup do shutup do
@ -1114,7 +1111,6 @@ class OutdatedVersionsTests < Homebrew::TestCase
system "git", "commit", "-m", "Initial commit" system "git", "commit", "-m", "Initial commit"
end end
end end
end
refute_predicate f.outdated_kegs(fetch_head: true), :empty? refute_predicate f.outdated_kegs(fetch_head: true), :empty?

View File

@ -76,7 +76,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase
repo_path = HOMEBREW_CACHE.join("repo") repo_path = HOMEBREW_CACHE.join("repo")
repo_path.join("bin").mkpath repo_path.join("bin").mkpath
using_git_env do
repo_path.cd do repo_path.cd do
shutup do shutup do
system "git", "init" system "git", "init"
@ -87,7 +86,6 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase
system "git", "commit", "-m", "Initial repo commit" system "git", "commit", "-m", "Initial repo commit"
end end
end end
end
setup_test_formula "testball1", <<-EOS.undent setup_test_formula "testball1", <<-EOS.undent
version "1.0" version "1.0"

View File

@ -16,18 +16,6 @@ module Test
ensure ensure
restore_env old restore_env old
end end
def using_git_env
git_env = ["AUTHOR", "COMMITTER"].each_with_object({}) do |role, env|
env["GIT_#{role}_NAME"] = "brew tests"
env["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
env["GIT_#{role}_DATE"] = "Sun Jan 22 19:59:13 2017 +0000"
end
with_environment(git_env) do
yield
end
end
end end
end end
end end

View File

@ -66,7 +66,6 @@ class TapTest < Homebrew::TestCase
end end
def setup_git_repo def setup_git_repo
using_git_env do
@path.cd do @path.cd do
shutup do shutup do
system "git", "init" system "git", "init"
@ -76,7 +75,6 @@ class TapTest < Homebrew::TestCase
end end
end end
end end
end
def test_fetch def test_fetch
assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew") assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew")