tests: more integration tests
Closes Homebrew/homebrew#48635. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
parent
9cab301185
commit
86eb44c96c
@ -2,6 +2,7 @@ require "bundler"
|
||||
require "testing_env"
|
||||
require "core_formula_repository"
|
||||
require "fileutils"
|
||||
require "pathname"
|
||||
|
||||
class IntegrationCommandTests < Homebrew::TestCase
|
||||
def setup
|
||||
@ -52,6 +53,7 @@ class IntegrationCommandTests < Homebrew::TestCase
|
||||
|
||||
def cmd(*args)
|
||||
output = cmd_output(*args)
|
||||
$stderr.write output unless $?.success?
|
||||
assert_equal 0, $?.exitstatus
|
||||
output
|
||||
end
|
||||
@ -326,6 +328,140 @@ class IntegrationCommandTests < Homebrew::TestCase
|
||||
(HOMEBREW_LIBRARY/"Taps").rmtree
|
||||
end
|
||||
|
||||
def test_unpack
|
||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
||||
content = <<-EOS.undent
|
||||
class Testball < Formula
|
||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
end
|
||||
EOS
|
||||
formula_file.write content
|
||||
|
||||
mktmpdir do |path|
|
||||
cmd "unpack", "testball", "--destdir=#{path}"
|
||||
assert File.directory?("#{path}/testball-0.1"),
|
||||
"The tarball should be unpacked"
|
||||
end
|
||||
ensure
|
||||
FileUtils.rm_f (HOMEBREW_CACHE/"testball-0.1.tbz")
|
||||
formula_file.unlink
|
||||
end
|
||||
|
||||
def test_options
|
||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
||||
content = <<-EOS.undent
|
||||
class Testball < Formula
|
||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
option "with-foo", "foobar"
|
||||
depends_on "bar" => :recommended
|
||||
end
|
||||
EOS
|
||||
formula_file.write content
|
||||
|
||||
assert_equal "--with-foo\n\tfoobar\n--without-bar\n\tBuild without bar support",
|
||||
cmd_output("options", "testball").chomp
|
||||
ensure
|
||||
formula_file.unlink
|
||||
end
|
||||
|
||||
def test_outdated
|
||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
||||
content = <<-EOS.undent
|
||||
class Testball < Formula
|
||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
end
|
||||
EOS
|
||||
formula_file.write content
|
||||
|
||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||
|
||||
assert_equal "testball", cmd("outdated")
|
||||
ensure
|
||||
formula_file.unlink
|
||||
FileUtils.rm_rf HOMEBREW_CELLAR/"testball"
|
||||
end
|
||||
|
||||
def test_upgrade
|
||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
||||
content = <<-EOS.undent
|
||||
class Testball < Formula
|
||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
sha256 "#{TESTBALL_SHA256}"
|
||||
|
||||
def install
|
||||
prefix.install Dir["*"]
|
||||
end
|
||||
end
|
||||
EOS
|
||||
formula_file.write content
|
||||
|
||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||
|
||||
cmd("upgrade")
|
||||
assert (HOMEBREW_CELLAR/"testball/0.1").directory?,
|
||||
"The latest version directory should be created"
|
||||
ensure
|
||||
formula_file.unlink
|
||||
cmd("uninstall", "--force", testball)
|
||||
cmd("cleanup", "--force", "--prune=all")
|
||||
end
|
||||
|
||||
def test_unlinkapps
|
||||
apps_dir = Pathname.new File.expand_path("~/Applications")
|
||||
apps_dir.mkpath
|
||||
|
||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
||||
content = <<-EOS.undent
|
||||
class Testball < Formula
|
||||
url "https://example.com/testball-0.1.tar.gz"
|
||||
end
|
||||
EOS
|
||||
formula_file.write content
|
||||
|
||||
source_app = (HOMEBREW_CELLAR/"testball/0.1/TestBall.app")
|
||||
source_app.mkpath
|
||||
|
||||
FileUtils.ln_s source_app, "#{apps_dir}/TestBall.app"
|
||||
|
||||
assert_match "Unlinking #{apps_dir}/TestBall.app",
|
||||
cmd("unlinkapps", "--local")
|
||||
ensure
|
||||
formula_file.unlink
|
||||
apps_dir.rmtree
|
||||
(HOMEBREW_CELLAR/"testball").rmtree
|
||||
end
|
||||
|
||||
def test_pin_unpin
|
||||
formula_file = CoreFormulaRepository.new.formula_dir/"testball.rb"
|
||||
content = <<-EOS.undent
|
||||
class Testball < Formula
|
||||
url "file://#{File.expand_path("..", __FILE__)}/tarballs/testball-0.1.tbz"
|
||||
sha256 "#{TESTBALL_SHA256}"
|
||||
|
||||
def install
|
||||
prefix.install Dir["*"]
|
||||
end
|
||||
end
|
||||
EOS
|
||||
formula_file.write content
|
||||
|
||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||
|
||||
cmd("pin", "testball")
|
||||
cmd("upgrade")
|
||||
refute (HOMEBREW_CELLAR/"testball/0.1").directory?,
|
||||
"The latest version directory should NOT be created"
|
||||
|
||||
cmd("unpin", "testball")
|
||||
cmd("upgrade")
|
||||
assert (HOMEBREW_CELLAR/"testball/0.1").directory?,
|
||||
"The latest version directory should be created"
|
||||
ensure
|
||||
formula_file.unlink
|
||||
cmd("uninstall", "--force", testball)
|
||||
cmd("cleanup", "--force", "--prune=all")
|
||||
end
|
||||
|
||||
def test_custom_command
|
||||
mktmpdir do |path|
|
||||
cmd = "int-test-#{rand}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user