Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 20, 2024
1 parent 8e2a492 commit bf9ee15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/async/container/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def initialize(**options)
@keyed = {}
end

attr :group

attr :state

# A human readable representation of the container.
Expand Down
27 changes: 27 additions & 0 deletions test/async/container/forked.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@
expect(container.statistics.restarts).to be == 2
end

it "can handle interrupts" do
finished = IO.pipe
interrupted = IO.pipe

container.spawn(restart: true) do |instance|
Thread.handle_interrupt(Interrupt => :never) do
instance.ready!

finished.first.gets
rescue ::Interrupt
interrupted.last.puts "incorrectly interrupted"
end
rescue ::Interrupt
interrupted.last.puts "correctly interrupted"
end

container.wait_until_ready

container.group.interrupt
sleep(0.001)
finished.last.puts "finished"

expect(interrupted.first.gets).to be == "correctly interrupted\n"

container.stop
end

it "should be multiprocess" do
expect(subject).to be(:multiprocess?)
end
Expand Down

0 comments on commit bf9ee15

Please sign in to comment.