aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorMike McQuaid2016-11-15 08:15:42 +0000
committerGitHub2016-11-15 08:15:42 +0000
commit484e3e0769d9eee760f46afb67fb2ce1bfe6e33d (patch)
tree4223979597492b8e36c7eb21c561fd6bd8a60d15 /Library/Homebrew/test
parent30fdbe089b6a7d91dd12132b46436f90dad60c88 (diff)
parentca3562645c30b86da5057cf2f8de9974c4a18413 (diff)
downloadbrew-484e3e0769d9eee760f46afb67fb2ce1bfe6e33d.tar.bz2
Merge pull request #1498 from alyssais/uninstall_developer_warning
Warn developers when uninstalling a dependency
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