Merge pull request #1328 from jawshooah/cask/fix-tests
Unset HOMEBREW_DEVELOPER in cask tests likely to raise deprecation errors
This commit is contained in:
commit
de5cadc447
@ -41,14 +41,14 @@ describe Hbc::CLI do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "respects the env variable when choosing what appdir to create" do
|
it "respects the env variable when choosing what appdir to create" do
|
||||||
EnvHelper.with_env_var("HOMEBREW_CASK_OPTS", "--appdir=/custom/appdir") do
|
with_environment "HOMEBREW_CASK_OPTS" => "--appdir=/custom/appdir" do
|
||||||
expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir"))
|
expect(Hbc).to receive(:appdir=).with(Pathname("/custom/appdir"))
|
||||||
described_class.process("noop")
|
described_class.process("noop")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "respects the env variable when choosing a non-default Caskroom location" do
|
it "respects the env variable when choosing a non-default Caskroom location" do
|
||||||
EnvHelper.with_env_var "HOMEBREW_CASK_OPTS", "--caskroom=/custom/caskdir" do
|
with_environment "HOMEBREW_CASK_OPTS" => "--caskroom=/custom/caskdir" do
|
||||||
expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir"))
|
expect(Hbc).to receive(:caskroom=).with(Pathname("/custom/caskdir"))
|
||||||
described_class.process("noop")
|
described_class.process("noop")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,6 +16,7 @@ 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(project_root.join("lib").to_s)
|
||||||
|
|
||||||
|
require "test/helper/env"
|
||||||
require "test/helper/shutup"
|
require "test/helper/shutup"
|
||||||
|
|
||||||
Dir["#{project_root}/spec/support/*.rb"].each(&method(:require))
|
Dir["#{project_root}/spec/support/*.rb"].each(&method(:require))
|
||||||
@ -61,5 +62,6 @@ Hbc.caskroom = Hbc.homebrew_prefix.join("TestCaskroom")
|
|||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.order = :random
|
config.order = :random
|
||||||
|
config.include(Test::Helper::Env)
|
||||||
config.include(Test::Helper::Shutup)
|
config.include(Test::Helper::Shutup)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
module EnvHelper
|
|
||||||
class << self
|
|
||||||
def with_env_var(key, val)
|
|
||||||
was_defined = ENV.key? "key"
|
|
||||||
old_value = ENV["key"]
|
|
||||||
ENV[key] = val
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
if was_defined
|
|
||||||
ENV[key] = old_value
|
|
||||||
else
|
|
||||||
ENV.delete(key)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,13 +1,15 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
describe "Casks" do
|
describe "Casks" do
|
||||||
Hbc.all.reject {|c| c.is_a?(Hbc::TestCask) }.each do |cask|
|
with_environment "HOMEBREW_DEVELOPER" => nil do
|
||||||
describe "#{cask}" do
|
Hbc.all.reject {|c| c.is_a?(Hbc::TestCask) }.each do |cask|
|
||||||
it "passes audit" do
|
describe "#{cask}" do
|
||||||
audit = Hbc::Audit.new(cask)
|
it "passes audit" do
|
||||||
audit.run!
|
audit = Hbc::Audit.new(cask)
|
||||||
audit.errors.must_equal [], "[#{cask}] Cask audit must be error free"
|
audit.run!
|
||||||
audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free"
|
audit.errors.must_equal [], "[#{cask}] Cask audit must be error free"
|
||||||
|
audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -69,11 +69,13 @@ describe Hbc::DSL do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "may use deprecated DSL version hash syntax" do
|
it "may use deprecated DSL version hash syntax" do
|
||||||
test_cask = Hbc.load("with-dsl-version")
|
with_environment "HOMEBREW_DEVELOPER" => nil do
|
||||||
test_cask.token.must_equal "with-dsl-version"
|
test_cask = Hbc.load("with-dsl-version")
|
||||||
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
|
test_cask.token.must_equal "with-dsl-version"
|
||||||
test_cask.homepage.must_equal "http://example.com/"
|
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
|
||||||
test_cask.version.to_s.must_equal "1.2.3"
|
test_cask.homepage.must_equal "http://example.com/"
|
||||||
|
test_cask.version.to_s.must_equal "1.2.3"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,9 @@ 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(project_root.join("lib").to_s)
|
||||||
|
|
||||||
|
require "test/helper/env"
|
||||||
require "test/helper/shutup"
|
require "test/helper/shutup"
|
||||||
|
include Test::Helper::Env
|
||||||
include Test::Helper::Shutup
|
include Test::Helper::Shutup
|
||||||
|
|
||||||
def sudo(*args)
|
def sudo(*args)
|
||||||
|
|||||||
15
Library/Homebrew/test/helper/env.rb
Normal file
15
Library/Homebrew/test/helper/env.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module Test
|
||||||
|
module Helper
|
||||||
|
module Env
|
||||||
|
def with_environment(partial_env)
|
||||||
|
old = ENV.to_hash
|
||||||
|
ENV.update partial_env
|
||||||
|
begin
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
ENV.replace old
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -63,7 +63,9 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TestCase < ::Minitest::Test
|
class TestCase < ::Minitest::Test
|
||||||
|
require "test/helper/env"
|
||||||
require "test/helper/shutup"
|
require "test/helper/shutup"
|
||||||
|
include Test::Helper::Env
|
||||||
include Test::Helper::Shutup
|
include Test::Helper::Shutup
|
||||||
|
|
||||||
include VersionAssertions
|
include VersionAssertions
|
||||||
@ -112,16 +114,6 @@ module Homebrew
|
|||||||
Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.bundle")
|
Pathname.new("#{TEST_DIRECTORY}/mach/#{name}.bundle")
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_environment(partial_env)
|
|
||||||
old = ENV.to_hash
|
|
||||||
ENV.update partial_env
|
|
||||||
begin
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
ENV.replace old
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Use a stubbed {Formulary::FormulaLoader} to make a given formula be found
|
# Use a stubbed {Formulary::FormulaLoader} to make a given formula be found
|
||||||
# when loading from {Formulary} with `ref`.
|
# when loading from {Formulary} with `ref`.
|
||||||
def stub_formula_loader(formula, ref = formula.full_name)
|
def stub_formula_loader(formula, ref = formula.full_name)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user