test/etc/test_etc.rb in etc-1.1.0 vs test/etc/test_etc.rb in etc-1.2.0
- old
+ new
@@ -42,21 +42,21 @@
end
s = passwd[Process.euid]
unless s.empty?
assert_include(s, Etc.getpwuid)
end
- end
+ end unless RUBY_PLATFORM.include?("android")
def test_getpwnam
passwd = {}
Etc.passwd do |s|
passwd[s.name] ||= s unless /\A\+/ =~ s.name
end
passwd.each_value do |s|
assert_equal(s, Etc.getpwnam(s.name))
end
- end
+ end unless RUBY_PLATFORM.include?("android")
def test_passwd_with_low_level_api
a = []
Etc.passwd {|s| a << s }
b = []
@@ -167,6 +167,29 @@
def test_nprocessors
n = Etc.nprocessors
assert_operator(1, :<=, n)
end
+ def test_ractor
+ return unless Etc.passwd # => skip test if no platform support
+
+ assert_ractor(<<~RUBY, require: 'etc')
+ ractor = Ractor.new do
+ Etc.passwd do |s|
+ Ractor.yield :sync
+ Ractor.yield s.name
+ break :done
+ end
+ end
+ ractor.take # => :sync
+ assert_raise RuntimeError, /parallel/ do
+ Etc.passwd {}
+ end
+ name = ractor.take # => first name
+ ractor.take # => :done
+ name2 = Etc.passwd do |s|
+ break s.name
+ end
+ assert_equal(name2, name)
+ RUBY
+ end
end