Fix some specs
This commit is contained in:
parent
801b661b4f
commit
348385e291
@ -9,7 +9,7 @@ class BottleSpecification
|
||||
|
||||
attr_reader :collector
|
||||
|
||||
sig { returns(T::Hash[String, T.untyped]) }
|
||||
sig { returns(T::Hash[Symbol, T.untyped]) }
|
||||
attr_reader :root_url_specs
|
||||
|
||||
sig { returns(String) }
|
||||
@ -20,7 +20,7 @@ class BottleSpecification
|
||||
@rebuild = T.let(0, Integer)
|
||||
@repository = T.let(Homebrew::DEFAULT_REPOSITORY, String)
|
||||
@collector = T.let(Utils::Bottles::Collector.new, Utils::Bottles::Collector)
|
||||
@root_url_specs = T.let({}, T::Hash[String, T.untyped])
|
||||
@root_url_specs = T.let({}, T::Hash[Symbol, T.untyped])
|
||||
@root_url = T.let(nil, T.nilable(String))
|
||||
end
|
||||
|
||||
|
||||
@ -37,11 +37,11 @@ module Homebrew
|
||||
|
||||
private
|
||||
|
||||
sig { returns(T::Hash[Symbol, T::Array[String]]) }
|
||||
sig { returns(T::Hash[Symbol, T.nilable(T::Array[String])]) }
|
||||
def skipped_entries
|
||||
return @skipped_entries if @skipped_entries
|
||||
|
||||
@skipped_entries ||= T.let({}, T.nilable(T::Hash[Symbol, T::Array[String]]))
|
||||
@skipped_entries ||= T.let({}, T.nilable(T::Hash[Symbol, T.nilable(T::Array[String])]))
|
||||
[:brew, :cask, :mas, :tap, :whalebrew].each do |type|
|
||||
@skipped_entries[type] =
|
||||
ENV["HOMEBREW_BUNDLE_#{type.to_s.upcase}_SKIP"]&.split
|
||||
|
||||
@ -12,6 +12,7 @@ module Cask
|
||||
#
|
||||
# @api internal
|
||||
class Config
|
||||
ConfigValue = T.type_alias { T.any(LazyObject, String, Pathname, T::Array[String]) }
|
||||
DEFAULT_DIRS = T.let(
|
||||
{
|
||||
appdir: "/Applications",
|
||||
@ -33,7 +34,7 @@ module Cask
|
||||
T::Hash[Symbol, String],
|
||||
)
|
||||
|
||||
sig { returns(T::Hash[Symbol, String]) }
|
||||
sig { returns(T::Hash[Symbol, T.any(LazyObject, String)]) }
|
||||
def self.defaults
|
||||
{
|
||||
languages: LazyObject.new { ::OS::Mac.languages },
|
||||
@ -79,12 +80,11 @@ module Cask
|
||||
|
||||
sig {
|
||||
params(
|
||||
config: T::Enumerable[
|
||||
[T.any(String, Symbol), T.any(String, Pathname, T::Array[String])],
|
||||
],
|
||||
).returns(
|
||||
T::Hash[Symbol, T.any(String, Pathname, T::Array[String])],
|
||||
)
|
||||
config: T.any(
|
||||
T::Hash[Symbol, T.any(LazyObject, String)],
|
||||
T::Enumerable[[T.any(String, Symbol), ConfigValue]],
|
||||
),
|
||||
).returns(T::Hash[Symbol, ConfigValue])
|
||||
}
|
||||
def self.canonicalize(config)
|
||||
config.to_h do |k, v|
|
||||
@ -93,7 +93,7 @@ module Cask
|
||||
if DEFAULT_DIRS.key?(key)
|
||||
raise TypeError, "Invalid path for default dir #{k}: #{v.inspect}" if v.is_a?(Array)
|
||||
|
||||
[key, Pathname(v).expand_path]
|
||||
[key, Pathname(v.to_s).expand_path]
|
||||
else
|
||||
[key, v]
|
||||
end
|
||||
@ -103,14 +103,14 @@ module Cask
|
||||
# Get the explicit configuration.
|
||||
#
|
||||
# @api internal
|
||||
sig { returns(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]) }
|
||||
sig { returns(T::Hash[Symbol, ConfigValue]) }
|
||||
attr_accessor :explicit
|
||||
|
||||
sig {
|
||||
params(
|
||||
default: T.nilable(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]),
|
||||
env: T.nilable(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]),
|
||||
explicit: T::Hash[Symbol, T.any(String, Pathname, T::Array[String])],
|
||||
default: T.nilable(T::Hash[Symbol, ConfigValue]),
|
||||
env: T.nilable(T::Hash[Symbol, ConfigValue]),
|
||||
explicit: T::Hash[Symbol, ConfigValue],
|
||||
ignore_invalid_keys: T::Boolean,
|
||||
).void
|
||||
}
|
||||
@ -118,18 +118,18 @@ module Cask
|
||||
if default
|
||||
@default = T.let(
|
||||
self.class.canonicalize(self.class.defaults.merge(default)),
|
||||
T.nilable(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]),
|
||||
T.nilable(T::Hash[Symbol, ConfigValue]),
|
||||
)
|
||||
end
|
||||
if env
|
||||
@env = T.let(
|
||||
self.class.canonicalize(env),
|
||||
T.nilable(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]),
|
||||
T.nilable(T::Hash[Symbol, ConfigValue]),
|
||||
)
|
||||
end
|
||||
@explicit = T.let(
|
||||
self.class.canonicalize(explicit),
|
||||
T::Hash[Symbol, T.any(String, Pathname, T::Array[String])],
|
||||
T::Hash[Symbol, ConfigValue],
|
||||
)
|
||||
|
||||
if ignore_invalid_keys
|
||||
@ -142,12 +142,12 @@ module Cask
|
||||
@explicit.assert_valid_keys(*self.class.defaults.keys)
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]) }
|
||||
sig { returns(T::Hash[Symbol, ConfigValue]) }
|
||||
def default
|
||||
@default ||= self.class.canonicalize(self.class.defaults)
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[Symbol, T.any(String, Pathname, T::Array[String])]) }
|
||||
sig { returns(T::Hash[Symbol, ConfigValue]) }
|
||||
def env
|
||||
@env ||= self.class.canonicalize(
|
||||
Homebrew::EnvConfig.cask_opts
|
||||
|
||||
@ -135,7 +135,7 @@ class DependencyCollector
|
||||
|
||||
sig {
|
||||
params(spec: T.any(String, Resource, Symbol, Requirement, Dependency, Class),
|
||||
tags: T::Array[Symbol]).returns(T.any(Dependency, Requirement, Array, NilClass))
|
||||
tags: T::Array[T.any(String, Symbol)]).returns(T.any(Dependency, Requirement, Array, NilClass))
|
||||
}
|
||||
def parse_spec(spec, tags)
|
||||
raise ArgumentError, "Implicit dependencies cannot be manually specified" if tags.include?(:implicit)
|
||||
|
||||
@ -643,7 +643,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
||||
args
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[Symbol, String]) }
|
||||
sig { returns(T::Hash[Symbol, T.any(String, Symbol)]) }
|
||||
def _curl_opts
|
||||
return { user_agent: meta.fetch(:user_agent) } if meta.key?(:user_agent)
|
||||
|
||||
|
||||
@ -283,7 +283,7 @@ module Kernel
|
||||
# @api public
|
||||
sig {
|
||||
type_parameters(:U)
|
||||
.params(hash: T::Hash[Object, String], _block: T.proc.returns(T.type_parameter(:U)))
|
||||
.params(hash: T::Hash[Object, T.nilable(String)], _block: T.proc.returns(T.type_parameter(:U)))
|
||||
.returns(T.type_parameter(:U))
|
||||
}
|
||||
def with_env(hash, &_block)
|
||||
|
||||
@ -3963,7 +3963,7 @@ class Formula
|
||||
# ```
|
||||
#
|
||||
# @api public
|
||||
sig { params(dep: T.any(String, Symbol, T::Hash[String, T.untyped], T::Class[Requirement])).void }
|
||||
sig { params(dep: T.any(String, Symbol, T::Hash[T.any(String, Symbol), T.untyped], T::Class[Requirement])).void }
|
||||
def depends_on(dep)
|
||||
specs.each { |spec| spec.depends_on(dep) }
|
||||
end
|
||||
|
||||
@ -28,4 +28,7 @@ class LazyObject < Delegator
|
||||
|
||||
__getobj__.is_a?(klass) || super
|
||||
end
|
||||
|
||||
def class = __getobj__.class
|
||||
def to_s = __getobj__.to_s
|
||||
end
|
||||
|
||||
@ -15,10 +15,10 @@ class XcodeRequirement < Requirement
|
||||
xcode_installed_version!
|
||||
end
|
||||
|
||||
sig { params(tags: T::Array[String]).void }
|
||||
sig { params(tags: T::Array[T.any(String, Symbol)]).void }
|
||||
def initialize(tags = [])
|
||||
version = tags.shift if tags.first.to_s.match?(/(\d\.)+\d/)
|
||||
@version = T.let(version, T.nilable(String))
|
||||
@version = T.let(version.to_s, T.nilable(String))
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ class SBOM
|
||||
include Utils::Output::Mixin
|
||||
|
||||
FILENAME = "sbom.spdx.json"
|
||||
SCHEMA_FILE = (HOMEBREW_LIBRARY_PATH/"data/schemas/sbom.json").freeze
|
||||
SCHEMA_FILE = T.let((HOMEBREW_LIBRARY_PATH/"data/schemas/sbom.json").freeze, Pathname)
|
||||
|
||||
# Instantiates a {SBOM} for a new installation of a formula.
|
||||
sig { params(formula: Formula, tab: Tab).returns(T.attached_class) }
|
||||
@ -85,7 +85,7 @@ class SBOM
|
||||
|
||||
sig { returns(T::Hash[String, T.untyped]) }
|
||||
def self.schema
|
||||
@schema ||= JSON.parse(SCHEMA_FILE.read, freeze: true)
|
||||
@schema ||= T.let(JSON.parse(SCHEMA_FILE.read, freeze: true), T.nilable(T::Hash[String, T.untyped]))
|
||||
end
|
||||
|
||||
sig { params(bottling: T::Boolean).returns(T::Array[T::Hash[String, T.untyped]]) }
|
||||
@ -134,17 +134,17 @@ class SBOM
|
||||
attr_reader :name, :homebrew_version, :time, :stdlib, :source, :built_on, :license
|
||||
attr_accessor :spdxfile
|
||||
|
||||
sig { params(attributes: Hash).void }
|
||||
sig { params(attributes: T::Hash[Symbol, T.untyped]).void }
|
||||
def initialize(attributes = {})
|
||||
attributes.each { |key, value| instance_variable_set(:"@#{key}", value) }
|
||||
end
|
||||
|
||||
sig {
|
||||
params(
|
||||
runtime_dependency_declaration: T::Array[Hash],
|
||||
compiler_declaration: Hash,
|
||||
runtime_dependency_declaration: T::Array[T::Hash[Symbol, T.untyped]],
|
||||
compiler_declaration: T::Hash[String, T.untyped],
|
||||
bottling: T::Boolean,
|
||||
).returns(T::Array[Hash])
|
||||
).returns(T::Array[T::Hash[Symbol, T.untyped]])
|
||||
}
|
||||
def generate_relations_json(runtime_dependency_declaration, compiler_declaration, bottling:)
|
||||
runtime = runtime_dependency_declaration.map do |dependency|
|
||||
@ -167,7 +167,7 @@ class SBOM
|
||||
spdxElementId: "SPDXRef-File-#{name}",
|
||||
relationshipType: "PACKAGE_OF",
|
||||
relatedSpdxElement: "SPDXRef-Archive-#{name}-src",
|
||||
}], T::Array[Hash])
|
||||
}], T::Array[T::Hash[Symbol, T.untyped]])
|
||||
|
||||
unless bottling
|
||||
base << {
|
||||
@ -189,16 +189,11 @@ class SBOM
|
||||
end
|
||||
|
||||
sig {
|
||||
params(runtime_dependency_declaration: T::Array[Hash],
|
||||
compiler_declaration: Hash,
|
||||
bottling: T::Boolean).returns(
|
||||
T::Array[
|
||||
T::Hash[
|
||||
Symbol,
|
||||
T.any(String, T::Array[T::Hash[Symbol, String]]),
|
||||
],
|
||||
],
|
||||
)
|
||||
params(
|
||||
runtime_dependency_declaration: T::Array[T::Hash[Symbol, T.untyped]],
|
||||
compiler_declaration: T::Hash[String, T.untyped],
|
||||
bottling: T::Boolean,
|
||||
).returns(T::Array[T::Hash[Symbol, T.untyped]])
|
||||
}
|
||||
def generate_packages_json(runtime_dependency_declaration, compiler_declaration, bottling:)
|
||||
bottle = []
|
||||
@ -302,7 +297,7 @@ class SBOM
|
||||
end
|
||||
end
|
||||
|
||||
sig { params(bottling: T::Boolean).returns(T::Hash[Symbol, T.any(String, T::Array[T::Hash[Symbol, String]])]) }
|
||||
sig { params(bottling: T::Boolean).returns(T::Hash[Symbol, T.anything]) }
|
||||
def to_spdx_sbom(bottling:)
|
||||
runtime_full = full_spdx_runtime_dependencies(bottling:)
|
||||
|
||||
|
||||
@ -242,7 +242,7 @@ class SoftwareSpec
|
||||
@build = BuildOptions.new(Options.create(@flags), options)
|
||||
end
|
||||
|
||||
sig { params(spec: T.any(String, Symbol, T::Hash[String, T.untyped], T::Class[Requirement], Dependable)).void }
|
||||
sig { params(spec: T.any(String, Symbol, T::Hash[T.any(String, Symbol), T.untyped], T::Class[Requirement], Dependable)).void }
|
||||
def depends_on(spec)
|
||||
dep = dependency_collector.add(spec)
|
||||
add_dep_option(dep) if dep
|
||||
|
||||
@ -480,7 +480,7 @@ class SystemCommand
|
||||
sig {
|
||||
params(
|
||||
command: T::Array[String],
|
||||
output: T::Array[[Symbol, String]],
|
||||
output: T::Array[[T.any(String, Symbol), String]],
|
||||
status: Process::Status,
|
||||
secrets: T::Array[String],
|
||||
).void
|
||||
|
||||
@ -67,7 +67,7 @@ RSpec.describe CurlDownloadStrategy do
|
||||
context "with a generalized fake user agent" do
|
||||
alias_matcher :a_string_matching, :match
|
||||
|
||||
let(:specs) { { user_agent: :fake } }
|
||||
let(:specs) { { user_agent: "fake" } }
|
||||
|
||||
it "adds the appropriate curl args" do
|
||||
expect(strategy).to receive(:system_command)
|
||||
|
||||
@ -33,6 +33,13 @@ module T
|
||||
recursively_valid?(obj)
|
||||
end
|
||||
end
|
||||
|
||||
class TypedHash < TypedEnumerable
|
||||
# overrides Base
|
||||
def valid?(obj)
|
||||
recursively_valid?(obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user