readall: fix no simulate
This wasn't working with casks because the bottle tag would be nil here. It was refactored to not use the bottle tag because casks don't have bottles. I also moved the valid_casks? method to extend/os/mac because casks only run on macOS and the generic OS tests were failing before.
This commit is contained in:
parent
140d444462
commit
0048b394d4
@ -1,10 +0,0 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Readall
|
||||
class << self
|
||||
def valid_casks?(_casks, bottle_tag: nil)
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
37
Library/Homebrew/extend/os/mac/readall.rb
Normal file
37
Library/Homebrew/extend/os/mac/readall.rb
Normal file
@ -0,0 +1,37 @@
|
||||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Readall
|
||||
class << self
|
||||
def valid_casks?(casks, os_name: nil, arch: Hardware::CPU.type)
|
||||
return true if os_name == :linux
|
||||
|
||||
current_macos_version = if os_name.is_a?(Symbol)
|
||||
MacOS::Version.from_symbol(os_name)
|
||||
else
|
||||
MacOS.version
|
||||
end
|
||||
|
||||
success = T.let(true, T::Boolean)
|
||||
casks.each do |file|
|
||||
cask = Cask::CaskLoader.load(file)
|
||||
|
||||
# Fine to have missing URLs for unsupported macOS
|
||||
macos_req = cask.depends_on.macos
|
||||
next if macos_req&.version && Array(macos_req.version).none? do |macos_version|
|
||||
current_macos_version.public_send(macos_req.comparator, macos_version)
|
||||
end
|
||||
|
||||
raise "Missing URL" if cask.url.nil?
|
||||
rescue Interrupt
|
||||
raise
|
||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||
os_and_arch = "macOS #{current_macos_version} on #{arch}"
|
||||
onoe "Invalid cask (#{os_and_arch}): #{file}"
|
||||
$stderr.puts e
|
||||
success = false
|
||||
end
|
||||
success
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,4 +1,4 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "extend/os/linux/readall" if OS.linux?
|
||||
require "extend/os/mac/readall" if OS.mac?
|
||||
|
||||
@ -62,28 +62,8 @@ module Readall
|
||||
success
|
||||
end
|
||||
|
||||
def valid_casks?(casks, bottle_tag: nil)
|
||||
return true if bottle_tag.present? && bottle_tag.system == :linux
|
||||
|
||||
success = T.let(true, T::Boolean)
|
||||
casks.each do |file|
|
||||
cask = Cask::CaskLoader.load(file)
|
||||
|
||||
# Fine to have missing URLs for unsupported macOS
|
||||
macos_req = cask.depends_on.macos
|
||||
next if macos_req&.version && Array(macos_req.version).none? do |macos_version|
|
||||
bottle_tag.to_macos_version.public_send(macos_req.comparator, macos_version)
|
||||
end
|
||||
|
||||
raise "Missing URL" if cask.url.nil?
|
||||
rescue Interrupt
|
||||
raise
|
||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||
onoe "Invalid cask (#{bottle_tag}): #{file}"
|
||||
$stderr.puts e
|
||||
success = false
|
||||
end
|
||||
success
|
||||
def valid_casks?(_casks, os_name: nil, arch: nil)
|
||||
true
|
||||
end
|
||||
|
||||
def valid_tap?(tap, options = {})
|
||||
@ -108,7 +88,7 @@ module Readall
|
||||
Homebrew::SimulateSystem.os = os_name
|
||||
|
||||
success = false unless valid_formulae?(tap.formula_files, bottle_tag: bottle_tag)
|
||||
success = false unless valid_casks?(tap.cask_files, bottle_tag: bottle_tag)
|
||||
success = false unless valid_casks?(tap.cask_files, os_name: os_name, arch: arch)
|
||||
ensure
|
||||
Homebrew::SimulateSystem.clear
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user