diff --git a/Library/Homebrew/api/formula_struct.rb b/Library/Homebrew/api/formula_struct.rb index 44b7be5f89110..44b86ec046a8f 100644 --- a/Library/Homebrew/api/formula_struct.rb +++ b/Library/Homebrew/api/formula_struct.rb @@ -47,8 +47,8 @@ def self.from_hash(formula_hash) T.any( # Formula name: "foo" String, - # Formula name and dependency type: { "foo" => :build } - T::Hash[String, Symbol], + # Formula name and dependency types: { "foo" => :build } or { "foo" => [:test, :no_linkage] } + T::Hash[String, T.any(Symbol, T::Array[Symbol])], ), # Requirements T.any( diff --git a/Library/Homebrew/test/api/formula_struct_spec.rb b/Library/Homebrew/test/api/formula_struct_spec.rb index 679367d8e0999..cb93a716dc18f 100644 --- a/Library/Homebrew/test/api/formula_struct_spec.rb +++ b/Library/Homebrew/test/api/formula_struct_spec.rb @@ -284,6 +284,21 @@ def build_formula_struct(checksums) expect(restored).to eq(original) end + it "preserves tagged dependencies after serialize then deserialize" do + original = described_class.new( + desc: "tagged dependencies", + homepage: "https://example.com", + license: "MIT", + ruby_source_checksum: "abc123", + stable_version: "1.0.0", + stable_dependencies: ["dep1", { "dep2" => :no_linkage }, { "dep3" => [:test, :no_linkage] }], + ) + + restored = described_class.deserialize(original.serialize) + + expect(restored.stable_dependencies).to eq(original.stable_dependencies) + end + it "serializes post-install steps", :needs_macos do original = described_class.new( desc: "install steps test",