brew/Library/Homebrew/test/utils/fork_spec.rb
William Woodruff 367629d289
utils: Use JSON to marshal child errors
Replaces our serialization of child process
errors via Marshal with JSON, preventing
unintentional or malicious code execution outside
of the build sandbox.

Additionally, adds tests for the new behavior.
2018-09-04 11:03:32 -04:00

22 lines
536 B
Ruby

require "utils/fork"
describe Utils do
describe "#safe_fork" do
it "raises a RuntimeError on an error that isn't ErrorDuringExecution" do
expect {
described_class.safe_fork do
raise "this is an exception in the child"
end
}.to raise_error(RuntimeError)
end
it "raises an ErrorDuringExecution on one in the child" do
expect {
described_class.safe_fork do
safe_system "/usr/bin/false"
end
}.to raise_error(ErrorDuringExecution)
end
end
end