diff --git a/Library/Homebrew/api.rb b/Library/Homebrew/api.rb index c88ef32fb5bfe..7dcc3c696da1c 100644 --- a/Library/Homebrew/api.rb +++ b/Library/Homebrew/api.rb @@ -184,11 +184,6 @@ def self.tap_from_source_download(path) Tap.fetch(org, repo) end - - sig { returns(T::Boolean) } - def self.internal_json_v3? - ENV["HOMEBREW_INTERNAL_JSON_V3"].present? - end end sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) } diff --git a/Library/Homebrew/api/formula.rb b/Library/Homebrew/api/formula.rb index d905bb4c85bb6..1bcd622da4f36 100644 --- a/Library/Homebrew/api/formula.rb +++ b/Library/Homebrew/api/formula.rb @@ -11,7 +11,6 @@ module Formula extend Cachable DEFAULT_API_FILENAME = "formula.jws.json" - INTERNAL_V3_API_FILENAME = "internal/v3/homebrew-core.jws.json" private_class_method :cache @@ -43,33 +42,24 @@ def self.source_download(formula) sig { returns(Pathname) } def self.cached_json_file_path - if Homebrew::API.internal_json_v3? - HOMEBREW_CACHE_API/INTERNAL_V3_API_FILENAME - else - HOMEBREW_CACHE_API/DEFAULT_API_FILENAME - end + HOMEBREW_CACHE_API/DEFAULT_API_FILENAME end sig { returns(T::Boolean) } def self.download_and_cache_data! - if Homebrew::API.internal_json_v3? - json_formulae, updated = Homebrew::API.fetch_json_api_file INTERNAL_V3_API_FILENAME - overwrite_cache! T.cast(json_formulae, T::Hash[String, T.untyped]) - else - json_formulae, updated = Homebrew::API.fetch_json_api_file DEFAULT_API_FILENAME - - cache["aliases"] = {} - cache["renames"] = {} - cache["formulae"] = json_formulae.to_h do |json_formula| - json_formula["aliases"].each do |alias_name| - cache["aliases"][alias_name] = json_formula["name"] - end - (json_formula["oldnames"] || [json_formula["oldname"]].compact).each do |oldname| - cache["renames"][oldname] = json_formula["name"] - end - - [json_formula["name"], json_formula.except("name")] + json_formulae, updated = Homebrew::API.fetch_json_api_file DEFAULT_API_FILENAME + + cache["aliases"] = {} + cache["renames"] = {} + cache["formulae"] = json_formulae.to_h do |json_formula| + json_formula["aliases"].each do |alias_name| + cache["aliases"][alias_name] = json_formula["name"] end + (json_formula["oldnames"] || [json_formula["oldname"]].compact).each do |oldname| + cache["renames"][oldname] = json_formula["name"] + end + + [json_formula["name"], json_formula.except("name")] end updated diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index 4a82c576f972f..ee1f6dcae6aa8 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -400,63 +400,15 @@ def to_h } end - def to_internal_api_hash - api_hash = { - "token" => token, - "name" => name, - "desc" => desc, - "homepage" => homepage, - "url" => url, - "version" => version, - "sha256" => sha256, - "artifacts" => artifacts_list(compact: true), - "ruby_source_path" => ruby_source_path, - "ruby_source_sha256" => ruby_source_checksum.fetch(:sha256), - } - - if deprecation_date - api_hash["deprecation_date"] = deprecation_date - api_hash["deprecation_reason"] = deprecation_reason - api_hash["deprecation_replacement"] = deprecation_replacement - end - - if disable_date - api_hash["disable_date"] = disable_date - api_hash["disable_reason"] = disable_reason - api_hash["disable_replacement"] = disable_replacement - end - - if (url_specs_hash = url_specs).present? - api_hash["url_specs"] = url_specs_hash - end - - api_hash["caskfile_only"] = true if caskfile_only? - api_hash["conflicts_with"] = conflicts_with if conflicts_with.present? - api_hash["depends_on"] = depends_on if depends_on.present? - api_hash["container"] = container.pairs if container - api_hash["caveats"] = caveats if caveats.present? - api_hash["auto_updates"] = auto_updates if auto_updates - api_hash["languages"] = languages if languages.present? - - api_hash - end - HASH_KEYS_TO_SKIP = %w[outdated installed versions].freeze private_constant :HASH_KEYS_TO_SKIP - def to_hash_with_variations(hash_method: :to_h) - case hash_method - when :to_h - if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api? - return api_to_local_hash(Homebrew::API::Cask.all_casks[token].dup) - end - when :to_internal_api_hash - raise ArgumentError, "API Hash must be generated from Ruby source files" if loaded_from_api? - else - raise ArgumentError, "Unknown hash method #{hash_method.inspect}" + def to_hash_with_variations + if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api? + return api_to_local_hash(Homebrew::API::Cask.all_casks[token].dup) end - hash = public_send(hash_method) + hash = to_h variations = {} if @dsl.on_system_blocks_exist? @@ -471,7 +423,7 @@ def to_hash_with_variations(hash_method: :to_h) Homebrew::SimulateSystem.with(os:, arch:) do refresh - public_send(hash_method).each do |key, value| + to_h.each do |key, value| next if HASH_KEYS_TO_SKIP.include? key next if value.to_s == hash[key].to_s @@ -485,11 +437,11 @@ def to_hash_with_variations(hash_method: :to_h) end end - hash["variations"] = variations if hash_method != :to_internal_api_hash || variations.present? + hash["variations"] = variations hash end - def artifacts_list(compact: false, uninstall_only: false) + def artifacts_list(uninstall_only: false) artifacts.filter_map do |artifact| case artifact when Artifact::AbstractFlightBlock @@ -498,8 +450,7 @@ def artifacts_list(compact: false, uninstall_only: false) next if uninstall_only && !uninstall_flight_block # Only indicate whether this block is used as we don't load it from the API - # We can skip this entirely once we move to internal JSON v3. - { artifact.summarize.to_sym => nil } unless compact + { artifact.summarize.to_sym => nil } else zap_artifact = artifact.is_a?(Artifact::Zap) uninstall_artifact = artifact.respond_to?(:uninstall_phase) || artifact.respond_to?(:post_uninstall_phase) diff --git a/Library/Homebrew/dev-cmd/generate-cask-api.rb b/Library/Homebrew/dev-cmd/generate-cask-api.rb index ac35895e3d75d..6f7582806171e 100644 --- a/Library/Homebrew/dev-cmd/generate-cask-api.rb +++ b/Library/Homebrew/dev-cmd/generate-cask-api.rb @@ -62,8 +62,6 @@ def run raise end - homebrew_cask_tap_json = JSON.generate(tap.to_internal_api_hash) - File.write("api/internal/v3/homebrew-cask.json", homebrew_cask_tap_json) unless args.dry_run? canonical_json = JSON.pretty_generate(tap.cask_renames) File.write("_data/cask_canonical.json", "#{canonical_json}\n") unless args.dry_run? end diff --git a/Library/Homebrew/dev-cmd/generate-formula-api.rb b/Library/Homebrew/dev-cmd/generate-formula-api.rb index a3fe69de0d31a..c87dc2a798179 100644 --- a/Library/Homebrew/dev-cmd/generate-formula-api.rb +++ b/Library/Homebrew/dev-cmd/generate-formula-api.rb @@ -60,8 +60,6 @@ def run raise end - homebrew_core_tap_json = JSON.generate(tap.to_internal_api_hash) - File.write("api/internal/v3/homebrew-core.json", homebrew_core_tap_json) unless args.dry_run? canonical_json = JSON.pretty_generate(tap.formula_renames.merge(tap.alias_table)) File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run? end diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index ac691843008d5..697a2a0684712 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -219,7 +219,6 @@ def setup_environment! # TODO: remove this and fix tests when possible. ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1" - ENV.delete("HOMEBREW_INTERNAL_JSON_V3") ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp diff --git a/Library/Homebrew/extend/cachable.rb b/Library/Homebrew/extend/cachable.rb index d3d2794bc38a4..b124c638e63ab 100644 --- a/Library/Homebrew/extend/cachable.rb +++ b/Library/Homebrew/extend/cachable.rb @@ -7,16 +7,8 @@ def cache @cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped])) end - # NOTE: We overwrite here instead of using `Hash#clear` to handle frozen hashes. sig { void } def clear_cache - overwrite_cache!({}) - end - - private - - sig { params(hash: T::Hash[T.untyped, T.untyped]).void } - def overwrite_cache!(hash) - @cache = hash + cache.clear end end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 4dbd9124f140d..889b6b6f58d3d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2572,85 +2572,8 @@ def to_hash hsh end - def to_internal_api_hash - api_hash = { - "desc" => desc, - "license" => SPDX.license_expression_to_string(license), - "homepage" => homepage, - "urls" => urls_hash.transform_values(&:compact), - "post_install_defined" => post_install_defined?, - "ruby_source_path" => ruby_source_path, - "ruby_source_sha256" => ruby_source_checksum&.hexdigest, - } - - # Exclude default values. - api_hash["revision"] = revision unless revision.zero? - api_hash["version_scheme"] = version_scheme unless version_scheme.zero? - - # Optional values. - api_hash["keg_only_reason"] = keg_only_reason.to_hash if keg_only_reason - api_hash["pour_bottle_only_if"] = self.class.pour_bottle_only_if.to_s if self.class.pour_bottle_only_if - api_hash["link_overwrite"] = self.class.link_overwrite_paths.to_a if self.class.link_overwrite_paths.present? - api_hash["caveats"] = caveats_with_placeholders if caveats - api_hash["service"] = service.to_hash if service? - - if stable - api_hash["version"] = stable&.version&.to_s - api_hash["bottle"] = bottle_hash(compact_for_api: true) if bottle_defined? - end - - if (versioned_formulae_list = versioned_formulae.presence) - # Could we just use `versioned_formulae_names` here instead? - api_hash["versioned_formulae"] = versioned_formulae_list.map(&:name) - end - - if (dependencies = internal_dependencies_hash(:stable).presence) - api_hash["dependencies"] = dependencies - end - - if (head_dependencies = internal_dependencies_hash(:head).presence) - api_hash["head_dependencies"] = head_dependencies - end - - if (requirements_array = serialized_requirements.presence) - api_hash["requirements"] = requirements_array - end - - if conflicts.present? - api_hash["conflicts_with"] = conflicts.map(&:name) - api_hash["conflicts_with_reasons"] = conflicts.map(&:reason) - end - - if deprecation_date - api_hash["deprecation_date"] = deprecation_date - api_hash["deprecation_reason"] = deprecation_reason - api_hash["deprecation_replacement"] = deprecation_replacement - end - - if disable_date - api_hash["disable_date"] = disable_date - api_hash["disable_reason"] = disable_reason - api_hash["disable_replacement"] = disable_replacement - end - - api_hash - end - - def to_hash_with_variations(hash_method: :to_hash) - if loaded_from_api? && hash_method == :to_internal_api_hash - raise ArgumentError, "API Hash must be generated from Ruby source files" - end - - namespace_prefix = case hash_method - when :to_hash - "Variations" - when :to_internal_api_hash - "APIVariations" - else - raise ArgumentError, "Unknown hash method #{hash_method.inspect}" - end - - hash = public_send(hash_method) + def to_hash_with_variations + hash = to_hash # Take from API, merging in local install status. if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api? @@ -2669,13 +2592,13 @@ def to_hash_with_variations(hash_method: :to_hash) next unless bottle_tag.valid_combination? Homebrew::SimulateSystem.with(os:, arch:) do - variations_namespace = Formulary.class_s("#{namespace_prefix}#{bottle_tag.to_sym.capitalize}") + variations_namespace = Formulary.class_s("Variations#{bottle_tag.to_sym.capitalize}") variations_formula_class = Formulary.load_formula(name, path, formula_contents, variations_namespace, flags: self.class.build_flags, ignore_errors: true) variations_formula = variations_formula_class.new(name, path, :stable, alias_path:, force_bottle:) - variations_formula.public_send(hash_method).each do |key, value| + variations_formula.to_hash.each do |key, value| next if value.to_s == hash[key].to_s variations[bottle_tag.to_sym] ||= {} @@ -2685,12 +2608,12 @@ def to_hash_with_variations(hash_method: :to_hash) end end - hash["variations"] = variations if hash_method != :to_internal_api_hash || variations.present? + hash["variations"] = variations hash end # Returns the bottle information for a formula. - def bottle_hash(compact_for_api: false) + def bottle_hash hash = {} stable_spec = stable return hash unless stable_spec @@ -2698,8 +2621,8 @@ def bottle_hash(compact_for_api: false) bottle_spec = stable_spec.bottle_specification - hash["rebuild"] = bottle_spec.rebuild if !compact_for_api || !bottle_spec.rebuild.zero? - hash["root_url"] = bottle_spec.root_url unless compact_for_api + hash["rebuild"] = bottle_spec.rebuild + hash["root_url"] = bottle_spec.root_url hash["files"] = {} bottle_spec.collector.each_tag do |tag| @@ -2710,11 +2633,9 @@ def bottle_hash(compact_for_api: false) file_hash = {} file_hash["cellar"] = os_cellar - unless compact_for_api - filename = Bottle::Filename.create(self, tag, bottle_spec.rebuild) - path, = Utils::Bottles.path_resolved_basename(bottle_spec.root_url, name, checksum, filename) - file_hash["url"] = "#{bottle_spec.root_url}/#{path}" - end + filename = Bottle::Filename.create(self, tag, bottle_spec.rebuild) + path, = Utils::Bottles.path_resolved_basename(bottle_spec.root_url, name, checksum, filename) + file_hash["url"] = "#{bottle_spec.root_url}/#{path}" file_hash["sha256"] = checksum hash["files"][tag.to_sym] = file_hash diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 0529671e9ad23..5dd9e2ec4cfa5 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -213,71 +213,38 @@ def self.load_formula_from_api(name, flags:) end end - add_deps = if Homebrew::API.internal_json_v3? - lambda do |deps| - T.bind(self, SoftwareSpec) - - deps&.each do |name, info| - tags = case info&.dig("tags") - in Array => tag_list - tag_list.map(&:to_sym) - in String => tag - tag.to_sym - else - nil - end + add_deps = lambda do |spec| + T.bind(self, SoftwareSpec) - if info&.key?("uses_from_macos") - bounds = info["uses_from_macos"].dup || {} - bounds.deep_transform_keys!(&:to_sym) - bounds.deep_transform_values!(&:to_sym) + dep_json = json_formula.fetch("#{spec}_dependencies", json_formula) - if tags - uses_from_macos name => tags, **bounds - else - uses_from_macos name, **bounds - end - elsif tags - depends_on name => tags - else - depends_on name - end - end - end - else - lambda do |spec| - T.bind(self, SoftwareSpec) + dep_json["dependencies"]&.each do |dep| + # Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux + next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) && + !Homebrew::SimulateSystem.simulating_or_running_on_macos? - dep_json = json_formula.fetch("#{spec}_dependencies", json_formula) + depends_on dep + end - dep_json["dependencies"]&.each do |dep| + [:build, :test, :recommended, :optional].each do |type| + dep_json["#{type}_dependencies"]&.each do |dep| # Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) && !Homebrew::SimulateSystem.simulating_or_running_on_macos? - depends_on dep - end - - [:build, :test, :recommended, :optional].each do |type| - dep_json["#{type}_dependencies"]&.each do |dep| - # Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux - next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) && - !Homebrew::SimulateSystem.simulating_or_running_on_macos? - - depends_on dep => type - end + depends_on dep => type end + end - dep_json["uses_from_macos"]&.each_with_index do |dep, index| - bounds = dep_json.fetch("uses_from_macos_bounds", [])[index].dup || {} - bounds.deep_transform_keys!(&:to_sym) - bounds.deep_transform_values!(&:to_sym) + dep_json["uses_from_macos"]&.each_with_index do |dep, index| + bounds = dep_json.fetch("uses_from_macos_bounds", [])[index].dup || {} + bounds.deep_transform_keys!(&:to_sym) + bounds.deep_transform_values!(&:to_sym) - if dep.is_a?(Hash) - uses_from_macos dep.deep_transform_values(&:to_sym).merge(bounds) - else - uses_from_macos dep, bounds - end + if dep.is_a?(Hash) + uses_from_macos dep.deep_transform_values(&:to_sym).merge(bounds) + else + uses_from_macos dep, bounds end end end @@ -299,15 +266,10 @@ def self.load_formula_from_api(name, flags:) using: urls_stable["using"]&.to_sym, }.compact url urls_stable["url"], **url_spec - version Homebrew::API.internal_json_v3? ? json_formula["version"] : json_formula["versions"]["stable"] + version json_formula["versions"]["stable"] sha256 urls_stable["checksum"] if urls_stable["checksum"].present? - if Homebrew::API.internal_json_v3? - instance_exec(json_formula["dependencies"], &add_deps) - else - instance_exec(:stable, &add_deps) - end - + instance_exec(:stable, &add_deps) requirements[:stable]&.each do |req| depends_on req end @@ -322,23 +284,14 @@ def self.load_formula_from_api(name, flags:) }.compact url urls_head["url"], **url_spec - if Homebrew::API.internal_json_v3? - instance_exec(json_formula["head_dependencies"], &add_deps) - else - instance_exec(:head, &add_deps) - end - + instance_exec(:head, &add_deps) requirements[:head]&.each do |req| depends_on req end end end - bottles_stable = if Homebrew::API.internal_json_v3? - json_formula["bottle"] - else - json_formula["bottle"]["stable"] - end.presence + bottles_stable = json_formula["bottle"]["stable"].presence if bottles_stable bottle do @@ -426,26 +379,20 @@ def caveats .gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home) end - @tap_git_head_string = if Homebrew::API.internal_json_v3? - Homebrew::API::Formula.tap_git_head - else - json_formula["tap_git_head"] - end + @tap_git_head_string = json_formula["tap_git_head"] def tap_git_head self.class.instance_variable_get(:@tap_git_head_string) end - unless Homebrew::API.internal_json_v3? - @oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact - def oldnames - self.class.instance_variable_get(:@oldnames_array) - end + @oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact + def oldnames + self.class.instance_variable_get(:@oldnames_array) + end - @aliases_array = json_formula.fetch("aliases", []) - def aliases - self.class.instance_variable_get(:@aliases_array) - end + @aliases_array = json_formula.fetch("aliases", []) + def aliases + self.class.instance_variable_get(:@aliases_array) end @versioned_formulae_array = json_formula.fetch("versioned_formulae", []) diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 52794cb99b57c..a00f95b9e1ed3 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -1307,8 +1307,6 @@ def tap_migrations @tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api? ensure_installed! super - elsif Homebrew::API.internal_json_v3? - Homebrew::API::Formula.tap_migrations else migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json", stale_seconds: TAP_MIGRATIONS_STALE_SECONDS @@ -1400,23 +1398,6 @@ def formula_files_by_name end end end - - sig { returns(T::Hash[String, T.untyped]) } - def to_internal_api_hash - formulae_api_hash = formula_names.to_h do |name| - formula = Formulary.factory(name) - formula_hash = formula.to_hash_with_variations(hash_method: :to_internal_api_hash) - [name, formula_hash] - end - - { - "tap_git_head" => git_head, - "aliases" => alias_table, - "renames" => formula_renames, - "tap_migrations" => tap_migrations, - "formulae" => formulae_api_hash, - } - end end # A specialized {Tap} class for homebrew-cask. @@ -1491,22 +1472,6 @@ def tap_migrations migrations end end - - sig { returns(T::Hash[String, T.untyped]) } - def to_internal_api_hash - casks_api_hash = cask_tokens.to_h do |token| - cask = Cask::CaskLoader.load(token) - cask_hash = cask.to_hash_with_variations(hash_method: :to_internal_api_hash) - [token, cask_hash] - end - - { - "tap_git_head" => git_head, - "renames" => cask_renames, - "tap_migrations" => tap_migrations, - "casks" => casks_api_hash, - } - end end # Permanent configuration per {Tap} using `git-config(1)`. diff --git a/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb b/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb deleted file mode 100644 index 6e79402e9934b..0000000000000 --- a/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb +++ /dev/null @@ -1,170 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "Internal Tap JSON -- Formula", type: :system do - include FileUtils - - let(:internal_tap_json) { File.read(TEST_FIXTURE_DIR/"internal_tap_json/homebrew-core.json").chomp } - let(:tap_git_head) { "9977471165641744a829d3e494fa563407503297" } - - context "when generating JSON", :needs_macos do - before do - cp_r(TEST_FIXTURE_DIR/"internal_tap_json/homebrew-core", HOMEBREW_TAP_DIRECTORY/"homebrew") - - # NOTE: Symlinks can't be copied recursively so we create them manually here. - (HOMEBREW_TAP_DIRECTORY/"homebrew/homebrew-core").tap do |core_tap| - mkdir(core_tap/"Aliases") - ln_s(core_tap/"Formula/f/fennel.rb", core_tap/"Aliases/fennel-lang") - ln_s(core_tap/"Formula/p/ponyc.rb", core_tap/"Aliases/ponyc-lang") - end - end - - it "creates the expected hash" do - api_hash = CoreTap.instance.to_internal_api_hash - api_hash["tap_git_head"] = tap_git_head # tricky to mock - - expect(JSON.pretty_generate(api_hash)).to eq(internal_tap_json) - end - end - - context "when loading JSON" do - before do - ENV["HOMEBREW_INTERNAL_JSON_V3"] = "1" - ENV.delete("HOMEBREW_NO_INSTALL_FROM_API") - - allow(Homebrew::API).to receive(:fetch_json_api_file) - .with("internal/v3/homebrew-core.jws.json") - .and_return([JSON.parse(internal_tap_json, freeze: true), false]) - - # `Tap.tap_migration_oldnames` looks for renames in every - # tap so `CoreCaskTap.tap_migrations` gets called and tries to - # fetch stuff from the API. This just avoids errors. - allow(Homebrew::API).to receive(:fetch_json_api_file) - .with("cask_tap_migrations.jws.json", anything) - .and_return([{}, false]) - - # To allow `formula_names.txt` to be written to the cache. - (HOMEBREW_CACHE/"api").mkdir - end - - it "loads tap aliases" do - expect(CoreTap.instance.alias_table).to eq({ - "fennel-lang" => "fennel", - "ponyc-lang" => "ponyc", - }) - end - - it "loads formula renames" do - expect(CoreTap.instance.formula_renames).to eq({ - "advancemenu" => "advancemame", - "amtk" => "libgedit-amtk", - "annie" => "lux", - "antlr2" => "antlr@2", - "romanesco" => "fennel", - }) - end - - it "loads tap migrations" do - expect(CoreTap.instance.tap_migrations).to eq({ - "adobe-air-sdk" => "homebrew/cask", - "android-ndk" => "homebrew/cask", - "android-platform-tools" => "homebrew/cask", - "android-sdk" => "homebrew/cask", - "app-engine-go-32" => "homebrew/cask/google-cloud-sdk", - }) - end - - it "loads tap git head" do - expect(Homebrew::API::Formula.tap_git_head) - .to eq(tap_git_head) - end - - context "when loading formulae" do - let(:fennel_metadata) do - { - "dependencies" => ["lua"], - "desc" => "Lua Lisp Language", - "full_name" => "fennel", - "homepage" => "https://fennel-lang.org", - "license" => "MIT", - "name" => "fennel", - "ruby_source_path" => "Formula/f/fennel.rb", - "tap" => "homebrew/core", - "tap_git_head" => tap_git_head, - "versions" => { "bottle"=>true, "head"=>nil, "stable"=>"1.4.0" }, - "ruby_source_checksum" => { - "sha256" => "5856e655fd1cea11496d67bc27fb14fee5cfbdea63c697c3773c7f247581197d", - }, - } - end - - let(:ponyc_metadata) do - { - "desc" => "Object-oriented, actor-model, capabilities-secure programming language", - "full_name" => "ponyc", - "homepage" => "https://www.ponylang.io/", - "license" => "BSD-2-Clause", - "name" => "ponyc", - "ruby_source_path" => "Formula/p/ponyc.rb", - "tap" => "homebrew/core", - "tap_git_head" => tap_git_head, - "uses_from_macos" => [{ "llvm"=>[:build, :test] }, "zlib"], - "uses_from_macos_bounds" => [{}, {}], - "versions" => { "bottle"=>true, "head"=>nil, "stable"=>"0.58.1" }, - "ruby_source_checksum" => { - "sha256" => "81d51c25d18710191beb62f9f380bae3d878aad815a65ec1ee2a3b132c1fadb3", - }, - } - end - - let(:inko_metadata) do - { - "desc" => "Safe and concurrent object-oriented programming language", - "full_name" => "inko", - "homepage" => "https://inko-lang.org/", - "license" => "MPL-2.0", - "name" => "inko", - "ruby_source_path" => "Formula/i/inko.rb", - "tap" => "homebrew/core", - "tap_git_head" => tap_git_head, - "dependencies" => ["llvm@15", "zstd"], - "uses_from_macos" => ["libffi", "ruby"], - "uses_from_macos_bounds" => [{ since: :catalina }, { since: :sierra }], - "versions" => { "bottle"=>true, "head"=>"HEAD", "stable"=>"0.14.0" }, - "ruby_source_checksum" => { - "sha256" => "843f6b5652483b971c83876201d68c95d5f32e67e55a75ac7c95d68c4350aa1c", - }, - } - end - - it "loads fennel" do - fennel = Formulary.factory("fennel") - expect(fennel.to_hash).to include(**fennel_metadata) - end - - it "loads fennel from rename" do - fennel = Formulary.factory("romanesco") - expect(fennel.to_hash).to include(**fennel_metadata) - end - - it "loads fennel from alias" do - fennel = Formulary.factory("fennel-lang") - expect(fennel.to_hash).to include(**fennel_metadata) - end - - it "loads ponyc" do - ponyc = Formulary.factory("ponyc") - expect(ponyc.to_hash).to include(**ponyc_metadata) - end - - it "loads ponyc from alias" do - ponyc = Formulary.factory("ponyc-lang") - expect(ponyc.to_hash).to include(**ponyc_metadata) - end - - it "loads ink" do - inko = Formulary.factory("inko") - expect(inko.to_hash).to include(**inko_metadata) - end - end - end -end diff --git a/Library/Homebrew/test/cask/cask_spec.rb b/Library/Homebrew/test/cask/cask_spec.rb index 038316a682715..30d2059f96e26 100644 --- a/Library/Homebrew/test/cask/cask_spec.rb +++ b/Library/Homebrew/test/cask/cask_spec.rb @@ -236,23 +236,6 @@ expect(cask.artifacts_list).to eq(expected_artifacts) end - it "skips flight blocks when compact is true" do - expected_artifacts = [ - { uninstall: [{ - rmdir: "#{TEST_TMPDIR}/empty_directory_path", - trash: ["#{TEST_TMPDIR}/foo", "#{TEST_TMPDIR}/bar"], - }] }, - { pkg: ["ManyArtifacts/ManyArtifacts.pkg"] }, - { app: ["ManyArtifacts/ManyArtifacts.app"] }, - { zap: [{ - rmdir: ["~/Library/Caches/ManyArtifacts", "~/Library/Application Support/ManyArtifacts"], - trash: "~/Library/Logs/ManyArtifacts.log", - }] }, - ] - - expect(cask.artifacts_list(compact: true)).to eq(expected_artifacts) - end - it "returns only uninstall artifacts when uninstall_only is true" do expected_artifacts = [ { uninstall_preflight: nil }, @@ -270,22 +253,6 @@ expect(cask.artifacts_list(uninstall_only: true)).to eq(expected_artifacts) end - - it "skips flight blocks and returns only uninstall artifacts when compact and uninstall_only are true" do - expected_artifacts = [ - { uninstall: [{ - rmdir: "#{TEST_TMPDIR}/empty_directory_path", - trash: ["#{TEST_TMPDIR}/foo", "#{TEST_TMPDIR}/bar"], - }] }, - { app: ["ManyArtifacts/ManyArtifacts.app"] }, - { zap: [{ - rmdir: ["~/Library/Caches/ManyArtifacts", "~/Library/Application Support/ManyArtifacts"], - trash: "~/Library/Logs/ManyArtifacts.log", - }] }, - ] - - expect(cask.artifacts_list(compact: true, uninstall_only: true)).to eq(expected_artifacts) - end end describe "#uninstall_flight_blocks?" do diff --git a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core.json b/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core.json deleted file mode 100644 index b704184417375..0000000000000 --- a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core.json +++ /dev/null @@ -1,218 +0,0 @@ -{ - "tap_git_head": "9977471165641744a829d3e494fa563407503297", - "aliases": { - "fennel-lang": "fennel", - "ponyc-lang": "ponyc" - }, - "renames": { - "advancemenu": "advancemame", - "amtk": "libgedit-amtk", - "annie": "lux", - "antlr2": "antlr@2", - "romanesco": "fennel" - }, - "tap_migrations": { - "adobe-air-sdk": "homebrew/cask", - "android-ndk": "homebrew/cask", - "android-platform-tools": "homebrew/cask", - "android-sdk": "homebrew/cask", - "app-engine-go-32": "homebrew/cask/google-cloud-sdk" - }, - "formulae": { - "fennel": { - "desc": "Lua Lisp Language", - "license": "MIT", - "homepage": "https://fennel-lang.org", - "urls": { - "stable": { - "url": "https://github.com/bakpakin/Fennel/archive/refs/tags/1.4.0.tar.gz", - "checksum": "161eb7f17f86e95de09070214d042fb25372f71ad266f451431f3109e87965c7" - } - }, - "post_install_defined": false, - "ruby_source_path": "Formula/f/fennel.rb", - "ruby_source_sha256": "5856e655fd1cea11496d67bc27fb14fee5cfbdea63c697c3773c7f247581197d", - "version": "1.4.0", - "bottle": { - "files": { - "all": { - "cellar": ":any_skip_relocation", - "sha256": "f46028597883cbc38864c61bd3fa402da9cb90ce97415d51a7b5279bc17f7bd0" - } - } - }, - "dependencies": { - "lua": null - } - }, - "inko": { - "desc": "Safe and concurrent object-oriented programming language", - "license": "MPL-2.0", - "homepage": "https://inko-lang.org/", - "urls": { - "stable": { - "url": "https://releases.inko-lang.org/0.14.0.tar.gz", - "checksum": "4e2c82911d6026f76c42ccc164dc45b1b5e331db2e9557460d9319d682668e65" - }, - "head": { - "url": "https://github.com/inko-lang/inko.git", - "branch": "main" - } - }, - "post_install_defined": false, - "ruby_source_path": "Formula/i/inko.rb", - "ruby_source_sha256": "843f6b5652483b971c83876201d68c95d5f32e67e55a75ac7c95d68c4350aa1c", - "version": "0.14.0", - "bottle": { - "files": { - "arm64_sonoma": { - "cellar": ":any", - "sha256": "f6ff66fdfb3aac69263c32a8a29d13e9d28a80ae33807f34460e55d8c1b228c6" - }, - "arm64_ventura": { - "cellar": ":any", - "sha256": "be59d916d29d85bb8bc4474eb1c7d42a56236835c3c21b0e36fb9e9df0a25e6e" - }, - "arm64_monterey": { - "cellar": ":any", - "sha256": "9522c1f89b997dedaa3167ce4dbfa4a2d8c660acddecd32a99a515922e851b52" - }, - "sonoma": { - "cellar": ":any", - "sha256": "8e32d823ce9712ae2d5a2b9cbe0c9b727223098b3e66b003da087032be9f6818" - }, - "ventura": { - "cellar": ":any", - "sha256": "178865db1e2b60b4085a2465e8a3879794030a6d22c99b58c95e4bdf5418ef1b" - }, - "monterey": { - "cellar": ":any", - "sha256": "6ef924939c42d7bb2ec4e0d65cf293147a593f829619928d2580b419ec19b26c" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "sha256": "14a02c119990d6a17062290439ac74e6667b41dcb90b18cd90b36d2a09715e10" - } - } - }, - "dependencies": { - "coreutils": { - "tags": [ - "build" - ] - }, - "rust": { - "tags": [ - "build" - ] - }, - "llvm@15": null, - "zstd": null, - "libffi": { - "uses_from_macos": { - "since": "catalina" - } - }, - "ruby": { - "uses_from_macos": { - "since": "sierra" - } - } - }, - "head_dependencies": { - "coreutils": { - "tags": [ - "build" - ] - }, - "rust": { - "tags": [ - "build" - ] - }, - "llvm@15": null, - "zstd": null, - "libffi": { - "uses_from_macos": { - "since": "catalina" - } - }, - "ruby": { - "uses_from_macos": { - "since": "sierra" - } - } - } - }, - "ponyc": { - "desc": "Object-oriented, actor-model, capabilities-secure programming language", - "license": "BSD-2-Clause", - "homepage": "https://www.ponylang.io/", - "urls": { - "stable": { - "url": "https://github.com/ponylang/ponyc.git", - "tag": "0.58.1", - "revision": "fe3895eb4af494bf36d7690641bdfb5755db8350" - } - }, - "post_install_defined": false, - "ruby_source_path": "Formula/p/ponyc.rb", - "ruby_source_sha256": "81d51c25d18710191beb62f9f380bae3d878aad815a65ec1ee2a3b132c1fadb3", - "version": "0.58.1", - "bottle": { - "files": { - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "sha256": "e3aecfcf02aea56d53d82691e2ad7a780f771023d7070271bfce96b17439a34d" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "sha256": "6ff83717191e16e4f852fb3be8f838afba312cc39e601bb5cebd2a618a328658" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "sha256": "25c91bce200583a96f4cea34f31393c8f10eadcab363cc7d4d864d15f5f97e25" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "sha256": "5f4c550ce33e2970e0ada18a409755fa62936181289a21c15582ff80343866b6" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "sha256": "f26c799f45013685da779bf2008ebe1907f9b3a93d5f260ce271a3f3b628da50" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "sha256": "1cff10d068b36b18b253d235424c4f5aef71ff9ee44f2522c4b041dd4383ec30" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "sha256": "ab49318d75eed3ee932c8e5add22f252ec0c852aad94945022877f926e93899f" - } - } - }, - "dependencies": { - "cmake": { - "tags": [ - "build" - ] - }, - "python@3.12": { - "tags": [ - "build" - ] - }, - "llvm": { - "tags": [ - "build", - "test" - ], - "uses_from_macos": null - }, - "zlib": { - "uses_from_macos": null - } - } - } - } -} diff --git a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/f/fennel.rb b/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/f/fennel.rb deleted file mode 100644 index c98a3f26c274f..0000000000000 --- a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/f/fennel.rb +++ /dev/null @@ -1,25 +0,0 @@ -class Fennel < Formula - desc "Lua Lisp Language" - homepage "https://fennel-lang.org" - url "https://github.com/bakpakin/Fennel/archive/refs/tags/1.4.0.tar.gz" - sha256 "161eb7f17f86e95de09070214d042fb25372f71ad266f451431f3109e87965c7" - license "MIT" - - bottle do - sha256 cellar: :any_skip_relocation, all: "f46028597883cbc38864c61bd3fa402da9cb90ce97415d51a7b5279bc17f7bd0" - end - - depends_on "lua" - - def install - system "make" - bin.install "fennel" - - lua = Formula["lua"] - (share/"lua"/lua.version.major_minor).install "fennel.lua" - end - - test do - assert_match "hello, world!", shell_output("#{bin}/fennel -e '(print \"hello, world!\")'") - end -end diff --git a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/i/inko.rb b/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/i/inko.rb deleted file mode 100644 index 9f56b2d0f4413..0000000000000 --- a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/i/inko.rb +++ /dev/null @@ -1,45 +0,0 @@ -class Inko < Formula - desc "Safe and concurrent object-oriented programming language" - homepage "https://inko-lang.org/" - url "https://releases.inko-lang.org/0.14.0.tar.gz" - sha256 "4e2c82911d6026f76c42ccc164dc45b1b5e331db2e9557460d9319d682668e65" - license "MPL-2.0" - head "https://github.com/inko-lang/inko.git", branch: "main" - - bottle do - sha256 cellar: :any, arm64_sonoma: "f6ff66fdfb3aac69263c32a8a29d13e9d28a80ae33807f34460e55d8c1b228c6" - sha256 cellar: :any, arm64_ventura: "be59d916d29d85bb8bc4474eb1c7d42a56236835c3c21b0e36fb9e9df0a25e6e" - sha256 cellar: :any, arm64_monterey: "9522c1f89b997dedaa3167ce4dbfa4a2d8c660acddecd32a99a515922e851b52" - sha256 cellar: :any, sonoma: "8e32d823ce9712ae2d5a2b9cbe0c9b727223098b3e66b003da087032be9f6818" - sha256 cellar: :any, ventura: "178865db1e2b60b4085a2465e8a3879794030a6d22c99b58c95e4bdf5418ef1b" - sha256 cellar: :any, monterey: "6ef924939c42d7bb2ec4e0d65cf293147a593f829619928d2580b419ec19b26c" - sha256 cellar: :any_skip_relocation, x86_64_linux: "14a02c119990d6a17062290439ac74e6667b41dcb90b18cd90b36d2a09715e10" - end - - depends_on "coreutils" => :build - depends_on "rust" => :build - depends_on "llvm@15" - depends_on "zstd" - - uses_from_macos "libffi", since: :catalina - uses_from_macos "ruby", since: :sierra - - def install - ENV.prepend_path "PATH", Formula["coreutils"].opt_libexec/"gnubin" - system "make", "build", "PREFIX=#{prefix}" - system "make", "install", "PREFIX=#{prefix}" - end - - test do - (testpath/"hello.inko").write <<~EOS - import std.stdio.STDOUT - - class async Main { - fn async main { - STDOUT.new.print('Hello, world!') - } - } - EOS - assert_equal "Hello, world!\n", shell_output("#{bin}/inko run hello.inko") - end -end diff --git a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/p/ponyc.rb b/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/p/ponyc.rb deleted file mode 100644 index 63ad8bdfab5f4..0000000000000 --- a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/Formula/p/ponyc.rb +++ /dev/null @@ -1,60 +0,0 @@ -class Ponyc < Formula - desc "Object-oriented, actor-model, capabilities-secure programming language" - homepage "https://www.ponylang.io/" - url "https://github.com/ponylang/ponyc.git", - tag: "0.58.1", - revision: "fe3895eb4af494bf36d7690641bdfb5755db8350" - license "BSD-2-Clause" - - bottle do - sha256 cellar: :any_skip_relocation, arm64_sonoma: "e3aecfcf02aea56d53d82691e2ad7a780f771023d7070271bfce96b17439a34d" - sha256 cellar: :any_skip_relocation, arm64_ventura: "6ff83717191e16e4f852fb3be8f838afba312cc39e601bb5cebd2a618a328658" - sha256 cellar: :any_skip_relocation, arm64_monterey: "25c91bce200583a96f4cea34f31393c8f10eadcab363cc7d4d864d15f5f97e25" - sha256 cellar: :any_skip_relocation, sonoma: "5f4c550ce33e2970e0ada18a409755fa62936181289a21c15582ff80343866b6" - sha256 cellar: :any_skip_relocation, ventura: "f26c799f45013685da779bf2008ebe1907f9b3a93d5f260ce271a3f3b628da50" - sha256 cellar: :any_skip_relocation, monterey: "1cff10d068b36b18b253d235424c4f5aef71ff9ee44f2522c4b041dd4383ec30" - sha256 cellar: :any_skip_relocation, x86_64_linux: "ab49318d75eed3ee932c8e5add22f252ec0c852aad94945022877f926e93899f" - end - - depends_on "cmake" => :build - depends_on "python@3.12" => :build - - uses_from_macos "llvm" => [:build, :test] - uses_from_macos "zlib" - - # We use LLVM to work around an error while building bundled `google-benchmark` with GCC - fails_with :gcc do - cause <<-EOS - .../src/gbenchmark/src/thread_manager.h:50:31: error: expected ')' before '(' token - 50 | GUARDED_BY(GetBenchmarkMutex()) Result results; - | ^ - EOS - end - - def install - inreplace "CMakeLists.txt", "PONY_COMPILER=\"${CMAKE_C_COMPILER}\"", "PONY_COMPILER=\"#{ENV.cc}\"" if OS.linux? - - ENV["CMAKE_FLAGS"] = "-DCMAKE_OSX_SYSROOT=#{MacOS.sdk_path}" if OS.mac? - ENV["MAKEFLAGS"] = "build_flags=-j#{ENV.make_jobs}" - - system "make", "libs" - system "make", "configure" - system "make", "build" - system "make", "install", "DESTDIR=#{prefix}" - end - - test do - # ENV["CC"] returns llvm_clang, which does not work in a test block. - ENV.clang - - system "#{bin}/ponyc", "-rexpr", "#{prefix}/packages/stdlib" - - (testpath/"test/main.pony").write <<~EOS - actor Main - new create(env: Env) => - env.out.print("Hello World!") - EOS - system "#{bin}/ponyc", "test" - assert_equal "Hello World!", shell_output("./test1").strip - end -end diff --git a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/formula_renames.json b/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/formula_renames.json deleted file mode 100644 index ff923dc297cd6..0000000000000 --- a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/formula_renames.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "advancemenu": "advancemame", - "amtk": "libgedit-amtk", - "annie": "lux", - "antlr2": "antlr@2", - "romanesco": "fennel" -} diff --git a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/tap_migrations.json b/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/tap_migrations.json deleted file mode 100644 index 2bdd3fd5c63b5..0000000000000 --- a/Library/Homebrew/test/support/fixtures/internal_tap_json/homebrew-core/tap_migrations.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "adobe-air-sdk": "homebrew/cask", - "android-ndk": "homebrew/cask", - "android-platform-tools": "homebrew/cask", - "android-sdk": "homebrew/cask", - "app-engine-go-32": "homebrew/cask/google-cloud-sdk" -}