aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorUladzislau Shablinski2016-12-11 14:26:46 +0300
committerGitHub2016-12-11 14:26:46 +0300
commit45ef7ea0b0ac8665d3eeae8acf0e17ef646be0b3 (patch)
tree5358d19dabb2ddb84459c1ea666e18da0522dbce /Library/Homebrew/test
parenta3bacf1238031067ba1ca3fba8d5611f490f3076 (diff)
parenta24a919a40f09930c5ef9f2fe811d16e83fa963a (diff)
downloadbrew-45ef7ea0b0ac8665d3eeae8acf0e17ef646be0b3.tar.bz2
Merge pull request #1343 from vladshablinsky/explicit-specs
Allow to install any spec
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/install_test.rb94
1 files changed, 94 insertions, 0 deletions
diff --git a/Library/Homebrew/test/install_test.rb b/Library/Homebrew/test/install_test.rb
index 9fe5fff0e..e047c0030 100644
--- a/Library/Homebrew/test/install_test.rb
+++ b/Library/Homebrew/test/install_test.rb
@@ -22,6 +22,100 @@ class IntegrationCommandTestInstall < IntegrationCommandTestCase
cmd("install", "testball2")
end
+ def test_install_failures
+ path = setup_test_formula "testball1", "version \"1.0\""
+ devel_content = <<-EOS.undent
+ version "3.0"
+ devel do
+ url "#{Formulary.factory("testball1").stable.url}"
+ sha256 "#{TESTBALL_SHA256}"
+ version "2.0"
+ end
+ EOS
+
+ assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
+
+ FileUtils.rm path
+ setup_test_formula "testball1", devel_content
+
+ assert_match "first `brew unlink testball1`", cmd_fail("install", "testball1")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("unlink", "testball1")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/2.0", cmd("install", "testball1", "--devel")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/2.0", cmd("unlink", "testball1")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/3.0", cmd("install", "testball1")
+
+ cmd("switch", "testball1", "2.0")
+ assert_match "already installed, however linked version is",
+ cmd("install", "testball1")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/2.0", cmd("unlink", "testball1")
+ assert_match "just not linked", cmd("install", "testball1")
+ end
+
+ def test_install_keg_only_outdated
+ path_keg_only = setup_test_formula "testball1", <<-EOS.undent
+ version "1.0"
+ keg_only "test reason"
+ EOS
+
+ assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
+
+ FileUtils.rm path_keg_only
+ setup_test_formula "testball1", <<-EOS.undent
+ version "2.0"
+ keg_only "test reason"
+ EOS
+
+ assert_match "keg-only and another version is linked to opt",
+ cmd("install", "testball1")
+
+ assert_match "#{HOMEBREW_CELLAR}/testball1/2.0",
+ cmd("install", "testball1", "--force")
+ end
+
+ def test_install_head_installed
+ initial_env = ENV.to_hash
+ %w[AUTHOR COMMITTER].each do |role|
+ ENV["GIT_#{role}_NAME"] = "brew tests"
+ ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost"
+ ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100"
+ end
+
+ repo_path = HOMEBREW_CACHE.join("repo")
+ repo_path.join("bin").mkpath
+
+ repo_path.cd do
+ shutup do
+ 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"
+ end
+ end
+
+ setup_test_formula "testball1", <<-EOS.undent
+ version "1.0"
+ head "file://#{repo_path}", :using => :git
+ def install
+ prefix.install Dir["*"]
+ end
+ EOS
+
+ # 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.
+ assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
+ assert_match "testball1-HEAD-2ccdf4f already installed",
+ cmd("install", "testball1", "--HEAD", "--ignore-dependencies")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/HEAD-2ccdf4f", cmd("unlink", "testball1")
+ assert_match "#{HOMEBREW_CELLAR}/testball1/1.0", cmd("install", "testball1")
+
+ ensure
+ ENV.replace(initial_env)
+ repo_path.rmtree
+ end
+
def test_install_with_invalid_option
setup_test_formula "testball1"
assert_match "testball1: this formula has no --with-fo option so it will be ignored!",