From 540347a42c965362eb5f05b5cb178e181932380a Mon Sep 17 00:00:00 2001 From: Bruce Steedman Date: Fri, 30 Sep 2016 18:41:54 +0100 Subject: [PATCH 1/6] fix tests failing when verbose set --- Library/Homebrew/test/test_download_strategies.rb | 2 ++ Library/Homebrew/test/test_outdated.rb | 6 +++++- Library/Homebrew/test/test_resource.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb index 87218fb12b..99c4ad1af2 100644 --- a/Library/Homebrew/test/test_download_strategies.rb +++ b/Library/Homebrew/test/test_download_strategies.rb @@ -22,11 +22,13 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase def test_expand_safe_system_args_with_explicit_quiet_flag @args << { quiet_flag: "--flag" } + ARGV.stubs(verbose?: false) expanded_args = @strategy.expand_safe_system_args(@args) assert_equal %w[foo bar baz --flag], expanded_args end def test_expand_safe_system_args_with_implicit_quiet_flag + ARGV.stubs(verbose?: false) expanded_args = @strategy.expand_safe_system_args(@args) assert_equal %w[foo bar -q baz], expanded_args end diff --git a/Library/Homebrew/test/test_outdated.rb b/Library/Homebrew/test/test_outdated.rb index cc0f024c8d..8ee3844df4 100644 --- a/Library/Homebrew/test/test_outdated.rb +++ b/Library/Homebrew/test/test_outdated.rb @@ -5,6 +5,10 @@ class IntegrationCommandTestOutdated < IntegrationCommandTestCase setup_test_formula "testball" (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - assert_equal "testball", cmd("outdated") + if ARGV.verbose? + assert_equal "testball (0.0.1) < 0.1", cmd("outdated") + else + assert_equal "testball", cmd("outdated") + end end end diff --git a/Library/Homebrew/test/test_resource.rb b/Library/Homebrew/test/test_resource.rb index c1b526cb2c..c7f82a169b 100644 --- a/Library/Homebrew/test/test_resource.rb +++ b/Library/Homebrew/test/test_resource.rb @@ -117,7 +117,7 @@ class ResourceTests < Homebrew::TestCase end def test_verify_download_integrity_mismatch - fn = stub(file?: true) + fn = stub(file?: true, basename: "Ftest") checksum = @resource.sha256(TEST_SHA256) fn.expects(:verify_checksum).with(checksum) From 0b293c44e8a9e8d67839fee9149debde27cb6f7b Mon Sep 17 00:00:00 2001 From: Bruce Steedman Date: Fri, 30 Sep 2016 23:41:41 +0100 Subject: [PATCH 2/6] fix remaining tap test failures --- Library/Homebrew/test/test_tap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index 1396d0a0eb..3b72c3c636 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -25,7 +25,7 @@ class IntegrationCommandTestTap < IntegrationCommandTestCase assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") assert_match "Untapped", cmd("untap", "homebrew/bar") - assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") + assert_match /.*/, cmd("tap", "homebrew/bar", path/".git", "-q", "--full") assert_match "Untapped", cmd("untap", "homebrew/bar") end end From d843f70a3501e05d81777ef9d0e8612fcaa1a659 Mon Sep 17 00:00:00 2001 From: Bruce Steedman Date: Fri, 30 Sep 2016 23:53:42 +0100 Subject: [PATCH 3/6] remove assertion, leave command --- Library/Homebrew/test/test_tap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index 3b72c3c636..368156e6ba 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -25,7 +25,7 @@ class IntegrationCommandTestTap < IntegrationCommandTestCase assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") assert_match "Untapped", cmd("untap", "homebrew/bar") - assert_match /.*/, cmd("tap", "homebrew/bar", path/".git", "-q", "--full") + cmd("tap", "homebrew/bar", path/".git", "-q", "--full") assert_match "Untapped", cmd("untap", "homebrew/bar") end end From df7246fdea9479d1131473b0babbecf35558dfda Mon Sep 17 00:00:00 2001 From: Bruce Steedman Date: Sat, 1 Oct 2016 09:26:25 +0100 Subject: [PATCH 4/6] make assertions conditional on ARGV.verbose? --- Library/Homebrew/test/test_download_strategies.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb index 99c4ad1af2..e349401855 100644 --- a/Library/Homebrew/test/test_download_strategies.rb +++ b/Library/Homebrew/test/test_download_strategies.rb @@ -22,15 +22,21 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase def test_expand_safe_system_args_with_explicit_quiet_flag @args << { quiet_flag: "--flag" } - ARGV.stubs(verbose?: false) expanded_args = @strategy.expand_safe_system_args(@args) - assert_equal %w[foo bar baz --flag], expanded_args + if ARGV.verbose? + assert_equal %w[foo bar baz], expanded_args + else + assert_equal %w[foo bar baz --flag], expanded_args + end end def test_expand_safe_system_args_with_implicit_quiet_flag - ARGV.stubs(verbose?: false) expanded_args = @strategy.expand_safe_system_args(@args) - assert_equal %w[foo bar -q baz], expanded_args + if ARGV.verbose? + assert_equal %w[foo bar baz], expanded_args + else + assert_equal %w[foo bar -q baz], expanded_args + end end def test_expand_safe_system_args_does_not_mutate_argument From 15462cc8178aa555334d2b67a7e3b6656bd7bf70 Mon Sep 17 00:00:00 2001 From: Bruce Steedman Date: Sat, 1 Oct 2016 09:49:06 +0100 Subject: [PATCH 5/6] delete verbose env vars in `brew tests` --- Library/Homebrew/dev-cmd/tests.rb | 2 ++ Library/Homebrew/test/test_download_strategies.rb | 12 ++---------- Library/Homebrew/test/test_outdated.rb | 6 +----- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 9b15f9f3ef..4e2d3b2db8 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -7,6 +7,8 @@ require "tap" module Homebrew def tests (HOMEBREW_LIBRARY/"Homebrew").cd do + ENV.delete "HOMEBREW_VERBOSE" + ENV.delete "VERBOSE" ENV["HOMEBREW_NO_ANALYTICS_THIS_RUN"] = "1" ENV["HOMEBREW_DEVELOPER"] = "1" ENV["TESTOPTS"] = "-v" if ARGV.verbose? diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb index e349401855..87218fb12b 100644 --- a/Library/Homebrew/test/test_download_strategies.rb +++ b/Library/Homebrew/test/test_download_strategies.rb @@ -23,20 +23,12 @@ class AbstractDownloadStrategyTests < Homebrew::TestCase def test_expand_safe_system_args_with_explicit_quiet_flag @args << { quiet_flag: "--flag" } expanded_args = @strategy.expand_safe_system_args(@args) - if ARGV.verbose? - assert_equal %w[foo bar baz], expanded_args - else - assert_equal %w[foo bar baz --flag], expanded_args - end + assert_equal %w[foo bar baz --flag], expanded_args end def test_expand_safe_system_args_with_implicit_quiet_flag expanded_args = @strategy.expand_safe_system_args(@args) - if ARGV.verbose? - assert_equal %w[foo bar baz], expanded_args - else - assert_equal %w[foo bar -q baz], expanded_args - end + assert_equal %w[foo bar -q baz], expanded_args end def test_expand_safe_system_args_does_not_mutate_argument diff --git a/Library/Homebrew/test/test_outdated.rb b/Library/Homebrew/test/test_outdated.rb index 8ee3844df4..cc0f024c8d 100644 --- a/Library/Homebrew/test/test_outdated.rb +++ b/Library/Homebrew/test/test_outdated.rb @@ -5,10 +5,6 @@ class IntegrationCommandTestOutdated < IntegrationCommandTestCase setup_test_formula "testball" (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - if ARGV.verbose? - assert_equal "testball (0.0.1) < 0.1", cmd("outdated") - else - assert_equal "testball", cmd("outdated") - end + assert_equal "testball", cmd("outdated") end end From c9733ba33ed56649cbce5d1afc393a17e040fe58 Mon Sep 17 00:00:00 2001 From: Bruce Steedman Date: Mon, 3 Oct 2016 14:28:25 +0100 Subject: [PATCH 6/6] revert changes --- Library/Homebrew/test/test_resource.rb | 2 +- Library/Homebrew/test/test_tap.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/test/test_resource.rb b/Library/Homebrew/test/test_resource.rb index c7f82a169b..c1b526cb2c 100644 --- a/Library/Homebrew/test/test_resource.rb +++ b/Library/Homebrew/test/test_resource.rb @@ -117,7 +117,7 @@ class ResourceTests < Homebrew::TestCase end def test_verify_download_integrity_mismatch - fn = stub(file?: true, basename: "Ftest") + fn = stub(file?: true) checksum = @resource.sha256(TEST_SHA256) fn.expects(:verify_checksum).with(checksum) diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index 368156e6ba..1396d0a0eb 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -25,7 +25,7 @@ class IntegrationCommandTestTap < IntegrationCommandTestCase assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") assert_match "Untapped", cmd("untap", "homebrew/bar") - cmd("tap", "homebrew/bar", path/".git", "-q", "--full") + assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") assert_match "Untapped", cmd("untap", "homebrew/bar") end end