mirror of
https://github.com/Homebrew/brew.git
synced 2026-08-12 22:29:27 +04:00
- Run each complete cask step block in one isolated subprocess and all generated completions in another phase-scoped sandbox. - Share sandbox selection, fork fallback, install-hook rules and child error reporting with formula build, post-install and test processes. - Restrict home, network and filesystem access while preserving `brew` and supporting explicit command write paths. - Keep JSON payloads compact and independent of cask Ruby files. - Remove the completed official-tap migration plan.
35 lines
918 B
Ruby
35 lines
918 B
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
require "utils/fork"
|
|
|
|
RSpec.describe Utils do
|
|
describe "::child_error_hash" do
|
|
it "preserves build error details" do
|
|
error = BuildError.new(nil, "make", ["install"], { "PATH" => "/bin" })
|
|
|
|
expect(described_class.child_error_hash(error)).to include(
|
|
"cmd" => "make", "args" => ["install"], "env" => { "PATH" => "/bin" },
|
|
)
|
|
end
|
|
end
|
|
|
|
describe "#safe_fork" do
|
|
it "raises a RuntimeError on an error that isn't ErrorDuringExecution" do
|
|
expect do
|
|
described_class.safe_fork do
|
|
raise "this is an exception in the child"
|
|
end
|
|
end.to raise_error(RuntimeError)
|
|
end
|
|
|
|
it "raises an ErrorDuringExecution on one in the child" do
|
|
expect do
|
|
described_class.safe_fork do
|
|
safe_system "/usr/bin/false"
|
|
end
|
|
end.to raise_error(ErrorDuringExecution)
|
|
end
|
|
end
|
|
end
|