| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | describe "brew install", :integration_test do | 
					
						
							|  |  |  |   it "installs Formulae" do | 
					
						
							|  |  |  |     setup_test_formula "testball1" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-25 09:01:24 +01:00
										 |  |  |       .and not_to_output.to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							| 
									
										
										
										
											2017-05-27 10:15:37 +01:00
										 |  |  |       .to output(/testball1\ 0\.1 is already installed/).to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and not_to_output.to_stdout | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "formula" } | 
					
						
							|  |  |  |       .to output(/No available formula/).to_stderr | 
					
						
							|  |  |  |       .and output(/Searching for similarly named formulae/).to_stdout | 
					
						
							|  |  |  |       .and be_a_failure | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setup_test_formula "testball2" | 
					
						
							|  |  |  |     install_and_rename_coretap_formula "testball1", "testball2" | 
					
						
							|  |  |  |     expect { brew "install", "testball2" } | 
					
						
							|  |  |  |       .to output(/testball1 already installed, it's just not migrated/).to_stderr | 
					
						
							| 
									
										
										
										
											2017-05-27 10:15:37 +01:00
										 |  |  |       .and not_to_output.to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   specify "install failures" do | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     path = setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       version "1.0" | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-25 09:01:24 +01:00
										 |  |  |       .and not_to_output.to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     FileUtils.rm path | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       version "2.0" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       devel do | 
					
						
							|  |  |  |         url "#{Formulary.factory("testball1").stable.url}" | 
					
						
							| 
									
										
										
										
											2017-03-14 22:38:43 -07:00
										 |  |  |         sha256 "#{Formulary.factory("testball1").stable.checksum.hexdigest}" | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |         version "3.0" | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							| 
									
										
										
										
											2017-04-25 12:45:37 +01:00
										 |  |  |       .to output(/`brew upgrade testball1`/).to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and not_to_output.to_stdout | 
					
						
							|  |  |  |       .and be_a_failure | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "unlink", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1", "--devel" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-25 09:01:24 +01:00
										 |  |  |       .and not_to_output.to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "unlink", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-25 09:01:24 +01:00
										 |  |  |       .and not_to_output.to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |     expect { brew "switch", "testball1", "3.0" }.to be_a_success | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							| 
									
										
										
										
											2017-05-27 10:15:37 +01:00
										 |  |  |       .to output(/2.0 is already installed/).to_stderr | 
					
						
							|  |  |  |       .and not_to_output.to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "unlink", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							|  |  |  |       .to output(/just not linked/).to_stderr | 
					
						
							|  |  |  |       .and not_to_output.to_stdout | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "can install keg-only Formulae" do | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     path_keg_only = setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       version "1.0" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       keg_only "test reason" | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     FileUtils.rm path_keg_only | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       version "2.0" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       keg_only "test reason" | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							| 
									
										
										
										
											2017-05-27 10:15:37 +01:00
										 |  |  |       .to output(/testball1 1.0 is already installed/).to_stderr | 
					
						
							|  |  |  |       .and not_to_output.to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1", "--force" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "can install HEAD Formulae" do | 
					
						
							|  |  |  |     repo_path = HOMEBREW_CACHE.join("repo") | 
					
						
							|  |  |  |     repo_path.join("bin").mkpath | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     repo_path.cd do | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |       system "git", "init" | 
					
						
							|  |  |  |       system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" | 
					
						
							|  |  |  |       FileUtils.touch "bin/something.bin" | 
					
						
							|  |  |  |       FileUtils.touch "README" | 
					
						
							|  |  |  |       system "git", "add", "--all" | 
					
						
							|  |  |  |       system "git", "commit", "-m", "Initial repo commit" | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       version "1.0" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       head "file://#{repo_path}", :using => :git | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       def install | 
					
						
							|  |  |  |         prefix.install Dir["*"] | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Ignore dependencies, because we'll try to resolve requirements in build.rb | 
					
						
							|  |  |  |     # and there will be the git requirement, but we cannot instantiate git | 
					
						
							|  |  |  |     # formula since we only have testball1 formula. | 
					
						
							|  |  |  |     expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-25 09:01:24 +01:00
										 |  |  |       .and output(/Cloning into/).to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" } | 
					
						
							| 
									
										
										
										
											2017-05-27 10:15:37 +01:00
										 |  |  |       .to output(/testball1 HEAD\-d5eb689 is already installed/).to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and not_to_output.to_stdout | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "unlink", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							|  |  |  |       .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-25 09:01:24 +01:00
										 |  |  |       .and not_to_output.to_stderr | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "ignores invalid options" do | 
					
						
							|  |  |  |     setup_test_formula "testball1" | 
					
						
							|  |  |  |     expect { brew "install", "testball1", "--with-fo" } | 
					
						
							|  |  |  |       .to output(/testball1: this formula has no \-\-with\-fo option so it will be ignored!/).to_stderr | 
					
						
							|  |  |  |       .and output(/Downloading file/).to_stdout | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "succeeds when a non-fatal requirement isn't satisfied" do | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       class NonFatalRequirement < Requirement | 
					
						
							| 
									
										
										
										
											2018-05-22 10:48:17 -07:00
										 |  |  |         satisfy(build_env: false) { false } | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       depends_on NonFatalRequirement | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							| 
									
										
										
										
											2017-04-23 15:10:18 +01:00
										 |  |  |       .to output(/NonFatalRequirement unsatisfied!/).to_stderr | 
					
						
							|  |  |  |       .and output(/built in/).to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "fails when a fatal requirement isn't satisfied" do | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     setup_test_formula "testball1", <<~RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       class FatalRequirement < Requirement | 
					
						
							|  |  |  |         fatal true | 
					
						
							|  |  |  |         satisfy { false } | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       depends_on FatalRequirement | 
					
						
							| 
									
										
										
										
											2018-07-11 15:17:40 +02:00
										 |  |  |     RUBY | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect { brew "install", "testball1" } | 
					
						
							| 
									
										
										
										
											2017-04-23 15:10:18 +01:00
										 |  |  |       .to output(/FatalRequirement unsatisfied!/).to_stderr | 
					
						
							|  |  |  |       .and not_to_output.to_stdout | 
					
						
							| 
									
										
										
										
											2017-02-23 06:06:02 +01:00
										 |  |  |       .and be_a_failure | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |