sleepy_penguin.git  about / heads / tags
Linux I/O events for Ruby
blob 8261168b8462c36847233c1a01d3de9e01fcbba4 495 bytes (raw)
$ git show v3.4.1:test/helper.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 
$-w = $stdout.sync = $stderr.sync = Thread.abort_on_exception = true
gem 'minitest'
require 'minitest/autorun'
Testcase = begin
  Minitest::Test # minitest 5
rescue NameError
  Minitest::Unit::TestCase # minitest 4
end

def check_cloexec(io)
  pipe = IO.pipe
  rbimp = Fcntl::FD_CLOEXEC & pipe[0].fcntl(Fcntl::F_GETFD)
  ours = Fcntl::FD_CLOEXEC & io.fcntl(Fcntl::F_GETFD)
  assert_equal rbimp, ours, "CLOEXEC default does not match Ruby implementation"
ensure
  pipe.each { |io| io.close }
end

git clone https://yhbt.net/sleepy_penguin.git