Skip to content

Commit 8c3e816

Browse files
committed
[GR-14806] Update specs
PullRequest: truffleruby/4154
2 parents 677ac08 + f29a775 commit 8c3e816

File tree

223 files changed

+4880
-4224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+4880
-4224
lines changed

spec/mspec/lib/mspec/runner/actions/leakchecker.rb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ def register
301301
end
302302

303303
def start
304+
disable_nss_modules
304305
@checker = LeakChecker.new
305306
end
306307

@@ -316,4 +317,61 @@ def after(state)
316317
end
317318
end
318319
end
320+
321+
private
322+
323+
# This function is intended to disable all NSS modules when ruby is compiled
324+
# against glibc. NSS modules allow the system administrator to load custom
325+
# shared objects into all processes using glibc, and use them to customise
326+
# the behaviour of username, groupname, hostname, etc lookups. This is
327+
# normally configured in the file /etc/nsswitch.conf.
328+
# These modules often do things like open cache files or connect to system
329+
# daemons like sssd or dbus, which of course means they have open file
330+
# descriptors of their own. This can cause the leak-checking functionality
331+
# in this file to report that such descriptors have been leaked, and fail
332+
# the test suite.
333+
# This function uses glibc's __nss_configure_lookup function to override any
334+
# configuration in /etc/nsswitch.conf, and just use the built in files/dns
335+
# name lookup functionality (which is of course perfectly sufficient for
336+
# running ruby/spec).
337+
def disable_nss_modules
338+
begin
339+
require 'fiddle'
340+
rescue LoadError
341+
# Make sure it's possible to run the test suite on a ruby implementation
342+
# which does not (yet?) have Fiddle.
343+
return
344+
end
345+
346+
begin
347+
libc = Fiddle.dlopen(nil)
348+
# Older versions of fiddle don't have Fiddle::Type (and instead rely on Fiddle::TYPE_)
349+
# Even older versions of fiddle don't have CONST_STRING,
350+
string_type = defined?(Fiddle::TYPE_CONST_STRING) ? Fiddle::TYPE_CONST_STRING : Fiddle::TYPE_VOIDP
351+
nss_configure_lookup = Fiddle::Function.new(
352+
libc['__nss_configure_lookup'],
353+
[string_type, string_type],
354+
Fiddle::TYPE_INT
355+
)
356+
rescue Fiddle::DLError
357+
# We're not running with glibc - no need to do this.
358+
return
359+
end
360+
361+
nss_configure_lookup.call 'passwd', 'files'
362+
nss_configure_lookup.call 'shadow', 'files'
363+
nss_configure_lookup.call 'group', 'files'
364+
nss_configure_lookup.call 'hosts', 'files dns'
365+
nss_configure_lookup.call 'services', 'files'
366+
nss_configure_lookup.call 'netgroup', 'files'
367+
nss_configure_lookup.call 'automount', 'files'
368+
nss_configure_lookup.call 'aliases', 'files'
369+
nss_configure_lookup.call 'ethers', 'files'
370+
nss_configure_lookup.call 'gshadow', 'files'
371+
nss_configure_lookup.call 'initgroups', 'files'
372+
nss_configure_lookup.call 'networks', 'files dns'
373+
nss_configure_lookup.call 'protocols', 'files'
374+
nss_configure_lookup.call 'publickey', 'files'
375+
nss_configure_lookup.call 'rpc', 'files'
376+
end
319377
end

spec/ruby/.rubocop.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ Lint/InterpolationCheck:
4343
Lint/LiteralAsCondition:
4444
Enabled: false
4545

46-
Lint/RedundantRequireStatement:
47-
Enabled: false
48-
4946
Lint/RedundantSplatExpansion:
5047
Enabled: false
5148

@@ -106,6 +103,9 @@ Lint/OutOfRangeRegexpRef:
106103
Lint/InheritException:
107104
Enabled: false
108105

106+
Lint/SafeNavigationChain:
107+
Enabled: false
108+
109109
Lint/ElseLayout:
110110
Exclude:
111111
- 'language/if_spec.rb'

spec/ruby/command_line/dash_v_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
it "prints version and ends" do
99
ruby_exe(nil, args: '-v').should include(RUBY_DESCRIPTION)
1010
end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) ||
11-
(defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?)
11+
(defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?) ||
12+
(ENV['RUBY_MN_THREADS'] == '1')
1213
end
1314
end

spec/ruby/core/array/rassoc_spec.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ def o.==(other); other == 'foobar'; end
3636
[[1, :foobar, o], [2, o, 1], [3, mock('foo')]].rassoc(key).should == [2, o, 1]
3737
end
3838

39-
it "does not call to_ary on non-array elements" do
40-
s1 = [1, 2]
41-
s2 = ArraySpecs::ArrayConvertible.new(2, 3)
42-
a = [s1, s2]
43-
44-
s1.should_not_receive(:to_ary)
45-
a.rassoc(2).should equal(s1)
46-
47-
s2.should_not_receive(:to_ary)
48-
a.rassoc(3).should equal(nil)
39+
ruby_version_is "3.3" do
40+
it "calls to_ary on non-array elements" do
41+
s1 = [1, 2]
42+
s2 = ArraySpecs::ArrayConvertible.new(2, 3)
43+
a = [s1, s2]
44+
45+
s1.should_not_receive(:to_ary)
46+
a.rassoc(2).should equal(s1)
47+
48+
a.rassoc(3).should == [2, 3]
49+
s2.called.should equal(:to_ary)
50+
end
4951
end
5052
end

spec/ruby/core/conditionvariable/broadcast_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require_relative '../../spec_helper'
2-
require 'thread'
32

43
describe "ConditionVariable#broadcast" do
54
it "releases all threads waiting in line for this resource" do

spec/ruby/core/conditionvariable/marshal_dump_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require_relative '../../spec_helper'
2-
require 'thread'
32

43
describe "ConditionVariable#marshal_dump" do
54
it "raises a TypeError" do

spec/ruby/core/conditionvariable/signal_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require_relative '../../spec_helper'
2-
require 'thread'
32

43
describe "ConditionVariable#signal" do
54
it "releases the first thread waiting in line for this resource" do

spec/ruby/core/conditionvariable/wait_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require_relative '../../spec_helper'
2-
require 'thread'
32

43
describe "ConditionVariable#wait" do
54
it "calls #sleep on the given object" do

spec/ruby/core/exception/frozen_error_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ def object.modify; @a = 2 end
3535
-> { object.modify }.should raise_error(FrozenError, /can't modify frozen .*?: \s*.../)
3636
end
3737
end
38-
end
38+
end

spec/ruby/core/file/atime_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
else
2828
File.atime(__FILE__).usec.should == 0
2929
end
30+
rescue Errno::ENOENT => e
31+
# Native Windows don't have stat command.
32+
skip e.message
3033
end
3134
end
3235
end

0 commit comments

Comments
 (0)