mirror of
https://github.com/Homebrew/brew.git
synced 2026-10-28 09:34:42 +08:00
Preserve build errors with Pathname arguments
- Stringify `BuildError` commands and arguments so JSON reporting preserves the original failure when formulae pass `Pathname`s. - Assert reconstructed fields so error equality cannot hide data loss. Fixes #24291
This commit is contained in:
1 parent
013821de5e
commit
b859f85125
2 files changed
+22
-2
No files matched your search
@@ -28,6 +28,26 @@ RSpec.describe Utils do
|
||||
end
|
||||
end
|
||||
|
||||
describe "::report_forked_child_error" do
|
||||
it "preserves a BuildError with Pathname commands and arguments" do
|
||||
error = BuildError.new(nil, Pathname("/bin/false"), ["arg1", 2, Pathname("arg 3"), :arg4], { "PATH" => "/bin" })
|
||||
error.set_backtrace ["/some/file.rb:1:in 'block'"]
|
||||
|
||||
IO.pipe do |reader, writer|
|
||||
described_class.report_forked_child_error(writer, error)
|
||||
|
||||
expect(described_class.rewrite_child_error(JSON.parse(reader.read))).to have_attributes(
|
||||
class: BuildError,
|
||||
cmd: "/bin/false",
|
||||
args: ["arg1", "2", "arg 3", "arg4"],
|
||||
env: { "PATH" => "/bin" },
|
||||
message: error.message,
|
||||
backtrace: error.backtrace,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#safe_fork" do
|
||||
it "reports only the parent error when the child reports a failure after disconnection" do
|
||||
handler = proc do |_message|
|
||||
|
||||
@@ -68,8 +68,8 @@ module Utils
|
||||
}
|
||||
case error
|
||||
when BuildError
|
||||
error_hash["cmd"] = error.cmd
|
||||
error_hash["args"] = error.args
|
||||
error_hash["cmd"] = error.cmd.to_s
|
||||
error_hash["args"] = error.args.map(&:to_s)
|
||||
error_hash["env"] = error.env
|
||||
when ErrorDuringExecution
|
||||
error_hash["cmd"] = error.cmd
|
||||
|
||||
Reference in new issue
Block a user