From 8a70b000e55dbeadf2372b1c75360ca837219605 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Tue, 14 Jun 2016 14:58:11 +0200 Subject: [PATCH] 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. --- .../Homebrew/test/test_integration_cmds.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb index 2640e2df61..4147ff87a3 100644 --- a/Library/Homebrew/test/test_integration_cmds.rb +++ b/Library/Homebrew/test/test_integration_cmds.rb @@ -717,19 +717,20 @@ class IntegrationCommandTests < Homebrew::TestCase end end - homebrew_core_clone = Pathname.new core_tap.path.dirname/"homebrew-core-clone" - shallow = Pathname.new homebrew_core_clone/".git/shallow" - - (core_tap.path.dirname).cd do - 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." + core_tap_url = "file://#{core_tap.path}" + shallow_tap = Tap.fetch("homebrew", "shallow") + shutup do + system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path 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 formula_file.unlink (core_tap.path/".git").rmtree - (core_tap.path.dirname/"homebrew-core-clone").rmtree + shallow_tap.path.rmtree end def test_leaves