| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | require "cmd/uninstall" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | describe "brew uninstall", :integration_test do | 
					
						
							|  |  |  |   it "uninstalls a given Formula" do | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |     expect { brew "install", testball }.to be_a_success | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "uninstall", "--force", testball } | 
					
						
							|  |  |  |       .to output(/Uninstalling testball/).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe Homebrew do | 
					
						
							|  |  |  |   let(:dependency) { formula("dependency") { url "f-1" } } | 
					
						
							|  |  |  |   let(:dependent) do | 
					
						
							|  |  |  |     formula("dependent") do | 
					
						
							|  |  |  |       url "f-1" | 
					
						
							|  |  |  |       depends_on "dependency" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   let(:opts) { { dependency.rack => [Keg.new(dependency.installed_prefix)] } } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   before do | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  |     [dependency, dependent].each do |f| | 
					
						
							|  |  |  |       f.installed_prefix.mkpath | 
					
						
							|  |  |  |       Keg.new(f.installed_prefix).optlink | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tab = Tab.empty | 
					
						
							|  |  |  |     tab.homebrew_version = "1.1.6" | 
					
						
							|  |  |  |     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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "::handle_unsatisfied_dependents" do | 
					
						
							|  |  |  |     specify "when developer" do | 
					
						
							| 
									
										
										
										
											2018-09-15 05:18:24 +02:00
										 |  |  |       ENV["HOMEBREW_DEVELOPER"] = "1" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  |       expect { | 
					
						
							|  |  |  |         described_class.handle_unsatisfied_dependents(opts) | 
					
						
							|  |  |  |       }.to output(/Warning/).to_stderr | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(described_class).not_to have_failed | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     specify "when not developer" do | 
					
						
							| 
									
										
										
										
											2018-09-15 05:18:24 +02:00
										 |  |  |       expect { | 
					
						
							|  |  |  |         described_class.handle_unsatisfied_dependents(opts) | 
					
						
							|  |  |  |       }.to output(/Error/).to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-15 05:18:24 +02:00
										 |  |  |       expect(described_class).to have_failed | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     specify "when not developer and --ignore-dependencies is specified" do | 
					
						
							| 
									
										
										
										
											2018-12-12 11:49:05 -08:00
										 |  |  |       described_class.args = described_class.args.dup if described_class.args.frozen? | 
					
						
							| 
									
										
										
										
											2018-11-11 17:43:31 +05:30
										 |  |  |       expect(described_class.args).to receive(:ignore_dependencies?).and_return(true) | 
					
						
							| 
									
										
										
										
											2018-12-12 11:49:05 -08:00
										 |  |  |       described_class.args.freeze | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-15 05:18:24 +02:00
										 |  |  |       expect { | 
					
						
							|  |  |  |         described_class.handle_unsatisfied_dependents(opts) | 
					
						
							|  |  |  |       }.not_to output.to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-15 05:18:24 +02:00
										 |  |  |       expect(described_class).not_to have_failed | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:42 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |