aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorAlyssa Ross2016-11-11 20:08:26 +0000
committerAlyssa Ross2016-11-14 12:13:34 +0000
commit3c310b2e3dd7805b04f48507c65c2c0a856c2aa2 (patch)
tree6349aa99f47facf9fb10b98e11301d84b79974a3 /Library/Homebrew/test
parent5294b99d6fa28b972ee4d695bda438bbf9e18647 (diff)
downloadbrew-3c310b2e3dd7805b04f48507c65c2c0a856c2aa2.tar.bz2
Warn developers when uninstalling a dependency
Suggested in #1084. Made the existing warning output entirely to STDERR, because previously the first line went to STDERR and subsequent ones went to STDOUT.
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_uninstall.rb41
-rw-r--r--Library/Homebrew/test/test_utils.rb4
2 files changed, 42 insertions, 3 deletions
diff --git a/Library/Homebrew/test/test_uninstall.rb b/Library/Homebrew/test/test_uninstall.rb
index a7859b7ad..c9b3e0be3 100644
--- a/Library/Homebrew/test/test_uninstall.rb
+++ b/Library/Homebrew/test/test_uninstall.rb
@@ -2,20 +2,55 @@ require "helper/integration_command_test_case"
require "cmd/uninstall"
class UninstallTests < Homebrew::TestCase
+ def setup
+ @dependency = formula("dependency") { url "f-1" }
+ @dependent = formula("dependent") do
+ url "f-1"
+ depends_on "dependency"
+ end
+
+ [@dependency, @dependent].each { |f| f.installed_prefix.mkpath }
+
+ tab = Tab.empty
+ tab.tabfile = @dependent.installed_prefix/Tab::FILENAME
+ tab.runtime_dependencies = [
+ { "full_name" => "dependency", "version" => "1" },
+ ]
+ tab.write
+
+ stub_formula_loader @dependency
+ stub_formula_loader @dependent
+ end
+
+ def teardown
+ Homebrew.failed = false
+ [@dependency, @dependent].each { |f| f.rack.rmtree }
+ end
+
+ def handle_unsatisfied_dependents
+ capture_stderr do
+ opts = { @dependency.rack => [Keg.new(@dependency.installed_prefix)] }
+ Homebrew.handle_unsatisfied_dependents(opts)
+ end
+ end
+
def test_check_for_testball_f2s_when_developer
- refute_predicate Homebrew, :should_check_for_dependents?
+ assert_match "Warning", handle_unsatisfied_dependents
+ refute_predicate Homebrew, :failed?
end
def test_check_for_dependents_when_not_developer
run_as_not_developer do
- assert_predicate Homebrew, :should_check_for_dependents?
+ assert_match "Error", handle_unsatisfied_dependents
+ assert_predicate Homebrew, :failed?
end
end
def test_check_for_dependents_when_ignore_dependencies
ARGV << "--ignore-dependencies"
run_as_not_developer do
- refute_predicate Homebrew, :should_check_for_dependents?
+ assert_empty handle_unsatisfied_dependents
+ refute_predicate Homebrew, :failed?
end
ensure
ARGV.delete("--ignore-dependencies")
diff --git a/Library/Homebrew/test/test_utils.rb b/Library/Homebrew/test/test_utils.rb
index 11332e450..7c0b6f78a 100644
--- a/Library/Homebrew/test/test_utils.rb
+++ b/Library/Homebrew/test/test_utils.rb
@@ -174,6 +174,10 @@ class UtilTests < Homebrew::TestCase
end
end
+ def test_capture_stderr
+ assert_equal "test\n", capture_stderr { $stderr.puts "test" }
+ end
+
def test_shell_profile
ENV["SHELL"] = "/bin/sh"
assert_equal "~/.bash_profile", Utils::Shell.shell_profile