Make fails_with available in spec blocks
Closes Homebrew/homebrew#31706.
This commit is contained in:
parent
00220c40db
commit
023f02b90a
@ -3,7 +3,6 @@ require 'formula_lock'
|
|||||||
require 'formula_pin'
|
require 'formula_pin'
|
||||||
require 'hardware'
|
require 'hardware'
|
||||||
require 'bottles'
|
require 'bottles'
|
||||||
require 'compilers'
|
|
||||||
require 'build_environment'
|
require 'build_environment'
|
||||||
require 'build_options'
|
require 'build_options'
|
||||||
require 'formulary'
|
require 'formulary'
|
||||||
@ -111,6 +110,10 @@ class Formula
|
|||||||
active_spec.option_defined?(name)
|
active_spec.option_defined?(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fails_with?(compiler)
|
||||||
|
active_spec.fails_with?(compiler)
|
||||||
|
end
|
||||||
|
|
||||||
# if the dir is there, but it's empty we consider it not installed
|
# if the dir is there, but it's empty we consider it not installed
|
||||||
def installed?
|
def installed?
|
||||||
(dir = installed_prefix).directory? && dir.children.length > 0
|
(dir = installed_prefix).directory? && dir.children.length > 0
|
||||||
@ -228,10 +231,6 @@ class Formula
|
|||||||
self.class.keg_only_reason
|
self.class.keg_only_reason
|
||||||
end
|
end
|
||||||
|
|
||||||
def fails_with? compiler
|
|
||||||
(self.class.cc_failures || []).any? { |failure| failure === compiler }
|
|
||||||
end
|
|
||||||
|
|
||||||
# sometimes the formula cleaner breaks things
|
# sometimes the formula cleaner breaks things
|
||||||
# skip cleaning paths in a formula with a class method like this:
|
# skip cleaning paths in a formula with a class method like this:
|
||||||
# skip_clean "bin/foo", "lib"bar"
|
# skip_clean "bin/foo", "lib"bar"
|
||||||
@ -609,7 +608,7 @@ class Formula
|
|||||||
class << self
|
class << self
|
||||||
include BuildEnvironmentDSL
|
include BuildEnvironmentDSL
|
||||||
|
|
||||||
attr_reader :keg_only_reason, :cc_failures
|
attr_reader :keg_only_reason
|
||||||
attr_rw :homepage, :plist_startup, :plist_manual, :revision
|
attr_rw :homepage, :plist_startup, :plist_manual, :revision
|
||||||
|
|
||||||
def specs
|
def specs
|
||||||
@ -742,16 +741,12 @@ class Formula
|
|||||||
# fails_with :gcc => '4.8' do
|
# fails_with :gcc => '4.8' do
|
||||||
# version '4.8.1'
|
# version '4.8.1'
|
||||||
# end
|
# end
|
||||||
def fails_with spec, &block
|
def fails_with compiler, &block
|
||||||
@cc_failures ||= Set.new
|
specs.each { |spec| spec.fails_with(compiler, &block) }
|
||||||
@cc_failures << CompilerFailure.create(spec, &block)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def needs *standards
|
def needs *standards
|
||||||
@cc_failures ||= Set.new
|
specs.each { |spec| spec.needs(*standards) }
|
||||||
standards.each do |standard|
|
|
||||||
@cc_failures.merge CompilerFailure.for_standard standard
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test &block
|
def test &block
|
||||||
|
|||||||
@ -7,6 +7,7 @@ require 'build_options'
|
|||||||
require 'dependency_collector'
|
require 'dependency_collector'
|
||||||
require 'bottles'
|
require 'bottles'
|
||||||
require 'patch'
|
require 'patch'
|
||||||
|
require 'compilers'
|
||||||
|
|
||||||
class SoftwareSpec
|
class SoftwareSpec
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
@ -21,6 +22,7 @@ class SoftwareSpec
|
|||||||
attr_reader :build, :resources, :patches, :options
|
attr_reader :build, :resources, :patches, :options
|
||||||
attr_reader :dependency_collector
|
attr_reader :dependency_collector
|
||||||
attr_reader :bottle_specification
|
attr_reader :bottle_specification
|
||||||
|
attr_reader :compiler_failures
|
||||||
|
|
||||||
def_delegators :@resource, :stage, :fetch, :verify_download_integrity
|
def_delegators :@resource, :stage, :fetch, :verify_download_integrity
|
||||||
def_delegators :@resource, :cached_download, :clear_cache
|
def_delegators :@resource, :cached_download, :clear_cache
|
||||||
@ -35,6 +37,7 @@ class SoftwareSpec
|
|||||||
@patches = []
|
@patches = []
|
||||||
@options = Options.new
|
@options = Options.new
|
||||||
@build = BuildOptions.new(Options.create(ARGV.options_only), options)
|
@build = BuildOptions.new(Options.create(ARGV.options_only), options)
|
||||||
|
@compiler_failures = []
|
||||||
end
|
end
|
||||||
|
|
||||||
def owner= owner
|
def owner= owner
|
||||||
@ -112,6 +115,20 @@ class SoftwareSpec
|
|||||||
patches << Patch.create(strip, src, &block)
|
patches << Patch.create(strip, src, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fails_with? compiler
|
||||||
|
compiler_failures.any? { |failure| failure === compiler }
|
||||||
|
end
|
||||||
|
|
||||||
|
def fails_with compiler, &block
|
||||||
|
compiler_failures << CompilerFailure.create(compiler, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def needs *standards
|
||||||
|
standards.each do |standard|
|
||||||
|
compiler_failures.concat CompilerFailure.for_standard(standard)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def add_legacy_patches(list)
|
def add_legacy_patches(list)
|
||||||
list = Patch.normalize_legacy_patches(list)
|
list = Patch.normalize_legacy_patches(list)
|
||||||
list.each { |p| p.owner = self }
|
list.each { |p| p.owner = self }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user