2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-17 22:42:37 -04:00
|
|
|
require "utils/fork"
|
|
|
|
|
2024-02-18 15:11:11 -08:00
|
|
|
RSpec.describe Utils do
|
2018-08-17 22:42:37 -04:00
|
|
|
describe "#safe_fork" do
|
|
|
|
it "raises a RuntimeError on an error that isn't ErrorDuringExecution" do
|
2023-03-08 23:14:46 +00:00
|
|
|
expect do
|
2018-08-17 22:42:37 -04:00
|
|
|
described_class.safe_fork do
|
|
|
|
raise "this is an exception in the child"
|
|
|
|
end
|
2023-03-08 23:14:46 +00:00
|
|
|
end.to raise_error(RuntimeError)
|
2018-08-17 22:42:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an ErrorDuringExecution on one in the child" do
|
2023-03-08 23:14:46 +00:00
|
|
|
expect do
|
2018-08-17 22:42:37 -04:00
|
|
|
described_class.safe_fork do
|
|
|
|
safe_system "/usr/bin/false"
|
|
|
|
end
|
2023-03-08 23:14:46 +00:00
|
|
|
end.to raise_error(ErrorDuringExecution)
|
2018-08-17 22:42:37 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|