Use test/lib/config for tests.
This commit is contained in:
parent
5b421b93c9
commit
a6c3ba7d86
@ -2,20 +2,16 @@ require "bundler"
|
|||||||
require "bundler/setup"
|
require "bundler/setup"
|
||||||
require "pathname"
|
require "pathname"
|
||||||
|
|
||||||
if ENV["HOMEBREW_TESTS_COVERAGE"]
|
require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
|
||||||
require "simplecov"
|
|
||||||
end
|
|
||||||
|
|
||||||
project_root = Pathname.new(File.expand_path("../..", __FILE__))
|
|
||||||
tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask")
|
|
||||||
|
|
||||||
# add Homebrew to load path
|
# add Homebrew to load path
|
||||||
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
|
||||||
|
$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew/test/lib"))
|
||||||
|
|
||||||
require "global"
|
require "global"
|
||||||
|
|
||||||
# add Homebrew-Cask to load path
|
# add Homebrew-Cask to load path
|
||||||
$LOAD_PATH.push(project_root.join("lib").to_s)
|
$LOAD_PATH.push(HOMEBREW_LIBRARY_PATH.join("cask", "lib").to_s)
|
||||||
|
|
||||||
require "test/helper/env"
|
require "test/helper/env"
|
||||||
require "test/helper/shutup"
|
require "test/helper/shutup"
|
||||||
@ -23,12 +19,7 @@ include Test::Helper::Env
|
|||||||
include Test::Helper::Shutup
|
include Test::Helper::Shutup
|
||||||
|
|
||||||
def sudo(*args)
|
def sudo(*args)
|
||||||
%w[/usr/bin/sudo -E --] + Array(args).flatten
|
%w[/usr/bin/sudo -E --] + args.flatten
|
||||||
end
|
|
||||||
|
|
||||||
TEST_TMPDIR = Dir.mktmpdir("homebrew_cask_tests")
|
|
||||||
at_exit do
|
|
||||||
FileUtils.remove_entry(TEST_TMPDIR)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# must be called after testing_env so at_exit hooks are in proper order
|
# must be called after testing_env so at_exit hooks are in proper order
|
||||||
@ -46,30 +37,20 @@ Mocha::Integration::MiniTest.activate
|
|||||||
# our baby
|
# our baby
|
||||||
require "hbc"
|
require "hbc"
|
||||||
|
|
||||||
# override Homebrew locations
|
module Hbc
|
||||||
Hbc.homebrew_prefix = Pathname.new(TEST_TMPDIR).join("prefix")
|
class TestCask < Cask; end
|
||||||
Hbc.homebrew_repository = Hbc.homebrew_prefix
|
|
||||||
|
|
||||||
# Override Tap::TAP_DIRECTORY to use our test Tap directory.
|
|
||||||
class Tap
|
|
||||||
send(:remove_const, :TAP_DIRECTORY)
|
|
||||||
TAP_DIRECTORY = Hbc.homebrew_prefix.join("Library", "Taps")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Hbc.default_tap = Tap.fetch("caskroom", "testcasks")
|
Hbc.cache.mkpath
|
||||||
|
Hbc.caskroom.mkpath
|
||||||
# also jack in some test Casks
|
Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap|
|
||||||
FileUtils.ln_s project_root.join("test", "support"), Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-testcasks")
|
# link test casks
|
||||||
|
FileUtils.mkdir_p tap.path.dirname
|
||||||
|
FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path
|
||||||
|
end
|
||||||
|
|
||||||
# pretend that the caskroom/cask Tap is installed
|
# pretend that the caskroom/cask Tap is installed
|
||||||
FileUtils.ln_s tap_root, Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-cask")
|
FileUtils.ln_s HOMEBREW_LIBRARY.join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path
|
||||||
|
|
||||||
# create cache directory
|
|
||||||
Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache")
|
|
||||||
Hbc.cache.mkpath
|
|
||||||
|
|
||||||
# our own testy caskroom
|
|
||||||
Hbc.caskroom = Hbc.homebrew_prefix.join("TestCaskroom")
|
|
||||||
|
|
||||||
class TestHelper
|
class TestHelper
|
||||||
# helpers for test Casks to reference local files easily
|
# helpers for test Casks to reference local files easily
|
||||||
@ -138,8 +119,3 @@ require "support/cleanup"
|
|||||||
require "support/never_sudo_system_command"
|
require "support/never_sudo_system_command"
|
||||||
require "tmpdir"
|
require "tmpdir"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
# Common superclass for test Casks for when we need to filter them out
|
|
||||||
module Hbc
|
|
||||||
class TestCask < Cask; end
|
|
||||||
end
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user