Fix update-report specs

This commit is contained in:
Douglas Eichelberger 2025-09-07 11:23:48 -07:00
parent 87025e33cf
commit ccbab836be
No known key found for this signature in database
GPG Key ID: F90193CBD547EB81
6 changed files with 48 additions and 15 deletions

View File

@ -121,9 +121,9 @@ class Build
end
new_env = {
"TMPDIR" => HOMEBREW_TEMP,
"TEMP" => HOMEBREW_TEMP,
"TMP" => HOMEBREW_TEMP,
"TMPDIR" => HOMEBREW_TEMP.to_s,
"TEMP" => HOMEBREW_TEMP.to_s,
"TMP" => HOMEBREW_TEMP.to_s,
}
with_env(new_env) do

View File

@ -427,6 +427,19 @@ require "extend/os/cmd/update-report"
class Reporter
include Utils::Output::Mixin
Report = T.type_alias do
{
A: T::Array[String],
AC: T::Array[String],
D: T::Array[String],
DC: T::Array[String],
M: T::Array[String],
MC: T::Array[String],
R: T::Array[[String, String]],
RC: T::Array[[String, String]],
}
end
class ReporterRevisionUnsetError < RuntimeError
sig { params(var_name: String).void }
def initialize(var_name)
@ -456,14 +469,14 @@ class Reporter
raise ReporterRevisionUnsetError, current_revision_var if @current_revision.empty?
end
@report = T.let(nil, T.nilable(T::Hash[Symbol, T::Array[String]]))
@report = T.let(nil, T.nilable(Report))
end
sig { params(auto_update: T::Boolean).returns(T::Hash[Symbol, T::Array[String]]) }
sig { params(auto_update: T::Boolean).returns(Report) }
def report(auto_update: false)
return @report if @report
@report = Hash.new { |h, k| h[k] = [] }
@report = T.unsafe(Hash.new { |h, k| h[k] = [] })
return @report unless updated?
diff.each_line do |line|
@ -791,13 +804,15 @@ class ReporterHub
sig { void }
def initialize
@hash = T.let({}, T::Hash[Symbol, T::Array[String]])
@hash = T.let({}, T::Hash[Symbol, T::Array[T.any(String, [String, String])]])
@reporters = T.let([], T::Array[Reporter])
end
sig { params(key: Symbol).returns(T::Array[String]) }
def select_formula_or_cask(key)
@hash.fetch(key, [])
raise "Unsupported key #{key}" unless [:A, :AC, :D, :DC, :M, :MC].include?(key)
T.cast(@hash.fetch(key, []), T::Array[String])
end
sig { params(reporter: Reporter, auto_update: T::Boolean).void }

View File

@ -119,7 +119,7 @@ module Homebrew
# seeds being output when running parallel tests.
seed = args.seed || rand(0xFFFF).to_i
bundle_args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
bundle_args = ["-I", (HOMEBREW_LIBRARY_PATH/"test").to_s]
bundle_args += %W[
--seed #{seed}
--color

View File

@ -34,7 +34,7 @@ module Kernel
sig { type_parameters(:U).params(block: T.proc.returns(T.type_parameter(:U))).returns(T.type_parameter(:U)) }
def with_homebrew_path(&block)
with_env(PATH: PATH.new(ORIGINAL_PATHS), &block)
with_env(PATH: PATH.new(ORIGINAL_PATHS).to_s, &block)
end
sig {

View File

@ -47,3 +47,21 @@ else
T::Configuration.call_validation_error_handler = ->(signature, opts) {}
T::Configuration.inline_type_error_handler = ->(error, opts) {}
end
module T
module Types
class TypedArray < TypedEnumerable
# overrides Base
def valid?(obj)
recursively_valid?(obj)
end
end
class TypedHash < TypedEnumerable
# overrides Base
def valid?(obj)
recursively_valid?(obj)
end
end
end
end

View File

@ -83,7 +83,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
expect(hub.select_formula_or_cask(:A)).to be_empty
expect(hub.select_formula_or_cask(:D)).to be_empty
expect(hub.select_formula_or_cask(:R)).to eq([["cv", "progress"]])
expect(hub.instance_variable_get(:@hash).fetch(:R, [])).to eq([["cv", "progress"]])
end
context "when updating a Tap other than the core Tap" do
@ -102,7 +102,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
expect(hub.select_formula_or_cask(:A)).to be_empty
expect(hub.select_formula_or_cask(:D)).to be_empty
expect(hub.select_formula_or_cask(:R)).to be_empty
expect(hub.instance_variable_get(:@hash).fetch(:R, [])).to be_empty
end
specify "with renamed Formula and restructured Tap" do
@ -111,7 +111,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
expect(hub.select_formula_or_cask(:A)).to be_empty
expect(hub.select_formula_or_cask(:D)).to be_empty
expect(hub.select_formula_or_cask(:R)).to eq([%w[foo/bar/xchat foo/bar/xchat2]])
expect(hub.instance_variable_get(:@hash).fetch(:R, [])).to eq([%w[foo/bar/xchat foo/bar/xchat2]])
end
specify "with simulated 'homebrew/php' restructuring" do
@ -119,7 +119,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
expect(hub.select_formula_or_cask(:A)).to be_empty
expect(hub.select_formula_or_cask(:D)).to be_empty
expect(hub.select_formula_or_cask(:R)).to be_empty
expect(hub.instance_variable_get(:@hash).fetch(:R, [])).to be_empty
end
specify "with Formula changes" do
@ -127,7 +127,7 @@ RSpec.describe Homebrew::Cmd::UpdateReport do
expect(hub.select_formula_or_cask(:A)).to eq(%w[foo/bar/lua])
expect(hub.select_formula_or_cask(:M)).to eq(%w[foo/bar/git])
expect(hub.select_formula_or_cask(:D)).to be_empty
expect(hub.instance_variable_get(:@hash).fetch(:R, [])).to be_empty
end
end
end