2015-11-19 07:54:27 -05:00
|
|
|
require "bundler"
|
2015-07-23 21:32:13 +01:00
|
|
|
require "testing_env"
|
|
|
|
|
|
|
|
class IntegrationCommandTests < Homebrew::TestCase
|
2015-08-03 13:09:07 +01:00
|
|
|
def cmd_output(*args)
|
2015-07-23 21:32:13 +01:00
|
|
|
cmd_args = %W[
|
2015-08-03 13:09:07 +01:00
|
|
|
-W0
|
|
|
|
-I#{HOMEBREW_LIBRARY_PATH}/test/lib
|
|
|
|
-rconfig
|
2015-07-23 21:32:13 +01:00
|
|
|
]
|
|
|
|
cmd_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
|
|
|
|
cmd_args << (HOMEBREW_LIBRARY_PATH/"../brew.rb").resolved_path.to_s
|
|
|
|
cmd_args += args
|
|
|
|
Bundler.with_original_env do
|
|
|
|
ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew"
|
|
|
|
ENV["HOMEBREW_INTEGRATION_TEST"] = args.join " "
|
|
|
|
ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR
|
|
|
|
Utils.popen_read(RUBY_PATH, *cmd_args).chomp
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def cmd(*args)
|
2015-07-23 21:32:13 +01:00
|
|
|
output = cmd_output(*args)
|
|
|
|
assert_equal 0, $?.exitstatus
|
|
|
|
output
|
|
|
|
end
|
|
|
|
|
2015-08-03 13:09:07 +01:00
|
|
|
def cmd_fail(*args)
|
2015-07-23 21:32:13 +01:00
|
|
|
output = cmd_output(*args)
|
|
|
|
assert_equal 1, $?.exitstatus
|
|
|
|
output
|
|
|
|
end
|
|
|
|
|
|
|
|
def testball
|
|
|
|
"#{File.expand_path("..", __FILE__)}/testball.rb"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_prefix
|
|
|
|
assert_equal HOMEBREW_PREFIX.to_s,
|
|
|
|
cmd("--prefix")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_version
|
2015-07-18 21:55:50 -07:00
|
|
|
assert_match HOMEBREW_VERSION.to_s,
|
2015-07-23 21:32:13 +01:00
|
|
|
cmd("--version")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_cache
|
|
|
|
assert_equal HOMEBREW_CACHE.to_s,
|
|
|
|
cmd("--cache")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_cache_formula
|
|
|
|
assert_match %r{#{HOMEBREW_CACHE}/testball-},
|
|
|
|
cmd("--cache", testball)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_cellar
|
|
|
|
assert_equal HOMEBREW_CELLAR.to_s,
|
|
|
|
cmd("--cellar")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_cellar_formula
|
|
|
|
assert_match "#{HOMEBREW_CELLAR}/testball",
|
|
|
|
cmd("--cellar", testball)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_env
|
2015-09-05 14:33:56 +08:00
|
|
|
assert_match %r{CMAKE_PREFIX_PATH="#{HOMEBREW_PREFIX}[:"]},
|
2015-07-23 21:32:13 +01:00
|
|
|
cmd("--env")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_prefix_formula
|
|
|
|
assert_match "#{HOMEBREW_CELLAR}/testball",
|
|
|
|
cmd("--prefix", testball)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_repository
|
|
|
|
assert_match HOMEBREW_REPOSITORY.to_s,
|
|
|
|
cmd("--repository")
|
|
|
|
end
|
2015-12-16 20:57:31 +00:00
|
|
|
|
|
|
|
def test_install
|
|
|
|
assert_match "#{HOMEBREW_CELLAR}/testball/0.1", cmd("install", testball)
|
|
|
|
ensure
|
|
|
|
cmd("uninstall", "--force", testball)
|
|
|
|
cmd("cleanup", "--force", "--prune=all")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_bottle
|
|
|
|
cmd("install", "--build-bottle", testball)
|
|
|
|
HOMEBREW_CACHE.cd do
|
|
|
|
assert_match(/testball-0\.1.*\.bottle\.tar\.gz/,
|
|
|
|
cmd_output("bottle", "--no-revision", testball))
|
|
|
|
end
|
|
|
|
ensure
|
|
|
|
cmd("uninstall", "--force", testball)
|
|
|
|
cmd("cleanup", "--force", "--prune=all")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_uninstall
|
|
|
|
cmd("install", "--build-bottle", testball)
|
|
|
|
assert_match "Uninstalling testball", cmd("uninstall", "--force", testball)
|
|
|
|
ensure
|
|
|
|
cmd("cleanup", "--force", "--prune=all")
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_cleanup
|
|
|
|
(HOMEBREW_CACHE/"test").write "test"
|
|
|
|
assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all")
|
|
|
|
end
|
2015-07-23 21:32:13 +01:00
|
|
|
end
|