tests: fix problems in 'log with formula' test (#350)

Problems fixed:

- Broken and leaking test if run as part of `brew tests --coverage` due
  to the `cmd` call being nested in the `Pathname#cd` block.
- Output during `git clone` operation because of a missing `shutup do`.
- Still incomplete coverage for `cmd/log.rb` because `brew log` is
  invoked on the formula in the origin instead of the shallow clone.
- Minor stylistic fixes:
  - Superfluous parentheses around `core_tap.path.dirname`.
  - Overly long lines.
This commit is contained in:
Martin Afanasjew 2016-06-14 14:58:11 +02:00 committed by GitHub
parent 86538c9d6a
commit 8a70b000e5

View File

@ -717,19 +717,20 @@ class IntegrationCommandTests < Homebrew::TestCase
end end
end end
homebrew_core_clone = Pathname.new core_tap.path.dirname/"homebrew-core-clone" core_tap_url = "file://#{core_tap.path}"
shallow = Pathname.new homebrew_core_clone/".git/shallow" shallow_tap = Tap.fetch("homebrew", "shallow")
shutup do
(core_tap.path.dirname).cd do system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
system "git", "clone", "--depth=1", "file://#{core_tap.path}", "homebrew-core-clone"
assert_match "This is a test commit for Testball", cmd("log", "testball")
assert_predicate shallow, :exist?, "A shallow clone should have been created."
end end
assert_match "This is a test commit for Testball",
cmd("log", "#{shallow_tap}/testball")
assert_predicate shallow_tap.path/".git/shallow", :exist?,
"A shallow clone should have been created."
ensure ensure
formula_file.unlink formula_file.unlink
(core_tap.path/".git").rmtree (core_tap.path/".git").rmtree
(core_tap.path.dirname/"homebrew-core-clone").rmtree shallow_tap.path.rmtree
end end
def test_leaves def test_leaves