aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2016-10-21 11:52:32 +0200
committerMarkus Reiter2016-10-21 17:39:19 +0200
commita6c3ba7d8602d6e03d2abd318102d83b98460fd0 (patch)
treee3abf98b4540019c12b69833057b478c546c4636 /Library
parent5b421b93c9897dd5bae60c24bb937cccdafa5574 (diff)
downloadbrew-a6c3ba7d8602d6e03d2abd318102d83b98460fd0.tar.bz2
Use `test/lib/config` for tests.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb52
1 files changed, 14 insertions, 38 deletions
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index de18a2869..b86ef59fa 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -2,20 +2,16 @@ require "bundler"
require "bundler/setup"
require "pathname"
-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")
+require "simplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
# 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/test/lib"))
require "global"
# 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/shutup"
@@ -23,12 +19,7 @@ include Test::Helper::Env
include Test::Helper::Shutup
def sudo(*args)
- %w[/usr/bin/sudo -E --] + Array(args).flatten
-end
-
-TEST_TMPDIR = Dir.mktmpdir("homebrew_cask_tests")
-at_exit do
- FileUtils.remove_entry(TEST_TMPDIR)
+ %w[/usr/bin/sudo -E --] + args.flatten
end
# must be called after testing_env so at_exit hooks are in proper order
@@ -46,30 +37,20 @@ Mocha::Integration::MiniTest.activate
# our baby
require "hbc"
-# override Homebrew locations
-Hbc.homebrew_prefix = Pathname.new(TEST_TMPDIR).join("prefix")
-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")
+module Hbc
+ class TestCask < Cask; end
end
-Hbc.default_tap = Tap.fetch("caskroom", "testcasks")
-
-# also jack in some test Casks
-FileUtils.ln_s project_root.join("test", "support"), Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-testcasks")
-
-# pretend that the caskroom/cask Tap is installed
-FileUtils.ln_s tap_root, Tap::TAP_DIRECTORY.join("caskroom").tap(&:mkpath).join("homebrew-cask")
-
-# create cache directory
-Hbc.homebrew_cache = Pathname.new(TEST_TMPDIR).join("cache")
Hbc.cache.mkpath
+Hbc.caskroom.mkpath
+Hbc.default_tap = Tap.fetch("caskroom", "test").tap do |tap|
+ # link test casks
+ FileUtils.mkdir_p tap.path.dirname
+ FileUtils.ln_s Pathname.new(__FILE__).dirname.join("support"), tap.path
+end
-# our own testy caskroom
-Hbc.caskroom = Hbc.homebrew_prefix.join("TestCaskroom")
+# pretend that the caskroom/cask Tap is installed
+FileUtils.ln_s HOMEBREW_LIBRARY.join("Taps", "caskroom", "homebrew-cask"), Tap.fetch("caskroom", "cask").path
class TestHelper
# helpers for test Casks to reference local files easily
@@ -138,8 +119,3 @@ require "support/cleanup"
require "support/never_sudo_system_command"
require "tmpdir"
require "tempfile"
-
-# Common superclass for test Casks for when we need to filter them out
-module Hbc
- class TestCask < Cask; end
-end