Skip to content

Commit 4c5fa17

Browse files
committed
[GR-14806] Update specs
PullRequest: truffleruby/3317
2 parents 7f9765a + 4c136f3 commit 4c5fa17

File tree

277 files changed

+3476
-7417
lines changed

Some content is hidden

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

277 files changed

+3476
-7417
lines changed

ci.jsonnet

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ local part_definitions = {
316316
"CHECK_LEAKS": "true",
317317
},
318318
run+: jt(["-u", mri_path(mri_version), "mspec", "spec/ruby"]) +
319-
jt(["-u", mri_path("2.7.2"), "mspec", "spec/ruby"]) +
320-
jt(["-u", mri_path("2.6.6"), "mspec", "spec/ruby"]),
319+
jt(["-u", mri_path("2.7.2"), "mspec", "spec/ruby"]),
321320
},
322321

323322
test_fast: {

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def initialize(timeout)
88
def register
99
MSpec.register :start, self
1010
MSpec.register :before, self
11+
MSpec.register :after, self
1112
MSpec.register :finish, self
1213
end
1314

@@ -35,8 +36,12 @@ def start
3536
if @queue.empty?
3637
elapsed = now - @started
3738
if elapsed > @timeout
38-
STDERR.puts "\n#{@current_state.description}"
39-
STDERR.puts "Example took longer than the configured timeout of #{@timeout}s"
39+
if @current_state
40+
STDERR.puts "\nExample took longer than the configured timeout of #{@timeout}s:"
41+
STDERR.puts "#{@current_state.description}"
42+
else
43+
STDERR.puts "\nSome code outside an example took longer than the configured timeout of #{@timeout}s"
44+
end
4045
STDERR.flush
4146

4247
show_backtraces
@@ -56,6 +61,12 @@ def before(state = nil)
5661
end
5762
end
5863

64+
def after(state = nil)
65+
@queue << -> do
66+
@current_state = nil
67+
end
68+
end
69+
5970
def finish
6071
@thread.kill
6172
@thread.join
@@ -73,7 +84,9 @@ def finish
7384
Truffle::Debug.show_backtraces
7485
else
7586
Thread.list.each do |thread|
76-
STDERR.puts thread.inspect, thread.backtrace, ''
87+
unless thread == Thread.current
88+
STDERR.puts thread.inspect, thread.backtrace, ''
89+
end
7790
end
7891
end
7992
end

spec/ruby/.rubocop.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4-
TargetRubyVersion: 2.6
4+
TargetRubyVersion: 2.7
55
DisplayCopNames: true
66
Exclude:
77
- command_line/fixtures/bad_syntax.rb
88
DisabledByDefault: true
9+
NewCops: disable
910

1011
Layout/TrailingWhitespace:
1112
Enabled: true
@@ -56,12 +57,52 @@ Lint/UnusedMethodArgument:
5657
Lint/UselessAssignment:
5758
Enabled: false
5859

59-
Lint/UselessComparison:
60+
Lint/BinaryOperatorWithIdenticalOperands:
6061
Enabled: false
6162

63+
Lint/EmptyConditionalBody:
64+
Enabled: false # buggy
65+
6266
Lint/Void:
6367
Enabled: false
6468

69+
Lint/ConstantDefinitionInBlock:
70+
Enabled: false
71+
72+
Lint/RaiseException:
73+
Enabled: false
74+
75+
Lint/FloatComparison:
76+
Enabled: false
77+
78+
Lint/DeprecatedClassMethods:
79+
Enabled: false
80+
81+
Lint/UnreachableLoop:
82+
Enabled: false
83+
84+
Lint/MissingSuper:
85+
Enabled: false
86+
87+
Lint/UselessMethodDefinition:
88+
Enabled: false
89+
90+
Lint/UselessTimes:
91+
Enabled: false
92+
93+
Lint/MixedRegexpCaptureTypes:
94+
Enabled: false
95+
96+
Lint/DuplicateElsifCondition:
97+
Enabled: false
98+
99+
Lint/OutOfRangeRegexpRef:
100+
Enabled: false
101+
102+
Lint/ElseLayout:
103+
Exclude:
104+
- 'language/if_spec.rb'
105+
65106
Lint/EmptyExpression:
66107
Exclude:
67108
- 'language/**/*.rb'

spec/ruby/CONTRIBUTING.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ Spec are grouped in 5 separate top-level groups:
1313
* `optional/capi`: for functions available to the Ruby C-extension API
1414

1515
The exact file for methods is decided by the `#owner` of a method, for instance for `#group_by`:
16+
1617
```ruby
1718
> [].method(:group_by)
1819
=> #<Method: Array(Enumerable)#group_by>
1920
> [].method(:group_by).owner
2021
=> Enumerable
2122
```
23+
2224
Which should therefore be specified in `core/enumerable/group_by_spec.rb`.
2325

2426
### MkSpec - a tool to generate the spec structure
@@ -178,7 +180,7 @@ First, file a bug at https://bugs.ruby-lang.org/.
178180
It is better to use a `ruby_version_is` guard if there was a release with the fix.
179181

180182
```ruby
181-
ruby_bug '#13669', ''...'2.7' do
183+
ruby_bug '#13669', ''...'3.2' do
182184
it "works like this" do
183185
# Specify the expected behavior here, not the bug
184186
end
@@ -220,7 +222,7 @@ If an implementation does not support some feature, simply tag the related specs
220222
### Shared Specs
221223

222224
Often throughout Ruby, identical functionality is used by different methods and modules. In order
223-
to avoid duplication of specs, we have shared specs that are re-used in other specs. The use is a
225+
to avoid duplication of specs, we have shared specs that are re-used in other specs. The use is a
224226
bit tricky however, so let's go over it.
225227

226228
Commonly, if a shared spec is only reused within its own module, the shared spec will live within a
@@ -232,7 +234,7 @@ An example of this is the `shared/file/socket.rb` which is used by `core/file/so
232234
`core/filetest/socket_spec.rb`, and `core/file/state/socket_spec.rb` and so it lives in the root `shared/`.
233235

234236
Defining a shared spec involves adding a `shared: true` option to the top-level `describe` block. This
235-
will signal not to run the specs directly by the runner. Shared specs have access to two instance
237+
will signal not to run the specs directly by the runner. Shared specs have access to two instance
236238
variables from the implementor spec: `@method` and `@object`, which the implementor spec will pass in.
237239

238240
Here's an example of a snippet of a shared spec and two specs which integrates it:
@@ -257,12 +259,12 @@ end
257259
```
258260

259261
In the example, the first `describe` defines the shared spec `:hash_key_p`, which defines a spec that
260-
calls the `@method` method with an expectation. In the implementor spec, we use `it_behaves_like` to
261-
integrate the shared spec. `it_behaves_like` takes 3 parameters: the key of the shared spec, a method,
262-
and an object. These last two parameters are accessible via `@method` and `@object` in the shared spec.
262+
calls the `@method` method with an expectation. In the implementor spec, we use `it_behaves_like` to
263+
integrate the shared spec. `it_behaves_like` takes 3 parameters: the key of the shared spec, a method,
264+
and an object. These last two parameters are accessible via `@method` and `@object` in the shared spec.
263265

264266
Sometimes, shared specs require more context from the implementor class than a simple object. We can address
265-
this by passing a lambda as the method, which will have the scope of the implementor. Here's an example of
267+
this by passing a lambda as the method, which will have the scope of the implementor. Here's an example of
266268
how this is used currently:
267269

268270
```ruby

spec/ruby/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ The specs describe the [language syntax](language/), the [core library](core/),
2424
The language specs are grouped by keyword while the core and standard library specs are grouped by class and method.
2525

2626
ruby/spec is known to be tested in these implementations for every commit:
27+
2728
* [MRI](https://rubyci.org/) on 30 platforms and 4 versions
2829
* [JRuby](https://github.com/jruby/jruby/tree/master/spec/ruby) for both 1.7 and 9.x
2930
* [TruffleRuby](https://github.com/oracle/truffleruby/tree/master/spec/ruby)
3031
* [Opal](https://github.com/opal/opal/tree/master/spec)
3132
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)
3233

33-
ruby/spec describes the behavior of Ruby 2.6 and more recent Ruby versions.
34-
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (2.6.x, 2.7.x, 3.0.x, etc), and those are tested in CI.
34+
ruby/spec describes the behavior of Ruby 2.7 and more recent Ruby versions.
35+
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (2.7.x, 3.0.x, 3.1.x, etc), and those are tested in CI.
3536

3637
### Synchronization with Ruby Implementations
3738

@@ -53,12 +54,14 @@ $ ../mspec/bin/mspec
5354
### Specs for old Ruby versions
5455

5556
For older specs try these commits:
57+
5658
* Ruby 2.0.0-p647 - [Suite](https://github.com/ruby/spec/commit/245862558761d5abc676843ef74f86c9bcc8ea8d) using [MSpec](https://github.com/ruby/mspec/commit/f90efa068791064f955de7a843e96e2d7d3041c2) (may encounter 2 failures)
5759
* Ruby 2.1.9 - [Suite](https://github.com/ruby/spec/commit/f029e65241374386077ac500add557ae65069b55) using [MSpec](https://github.com/ruby/mspec/commit/55568ea3918c6380e64db8c567d732fa5781efed)
5860
* Ruby 2.2.10 - [Suite](https://github.com/ruby/spec/commit/cbaa0e412270c944df0c2532fc500c920dba0e92) using [MSpec](https://github.com/ruby/mspec/commit/d84d7668449e96856c5f6bac8cb1526b6d357ce3)
5961
* Ruby 2.3.8 - [Suite](https://github.com/ruby/spec/commit/dc733114d8ae66a3368ba3a98422c50147a76ba5) using [MSpec](https://github.com/ruby/mspec/commit/4599bc195fb109f2a482a01c32a7d659518369ea)
6062
* Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/bce4f2b81d6c31db67cf4d023a0625ceadde59bd) using [MSpec](https://github.com/ruby/mspec/commit/e7eb8aa4c26495b7b461e687d950b96eb08b3ff2)
6163
* Ruby 2.5.9 - [Suite](https://github.com/ruby/spec/commit/c503335d3d9f6ec6ef24de60a0716c34af69b64f) using [MSpec](https://github.com/ruby/mspec/commit/0091e8a62e954717cd54641f935eaf1403692041)
64+
* Ruby 2.6.10 - [Suite](https://github.com/ruby/spec/commit/aaf998fb8c92c4e63ad423a2e7ca6e6921818c6e) using [MSpec](https://github.com/ruby/mspec/commit/5e36c684e9e2b92b1187589bba1df22c640a8661)
6265

6366
### Running the specs
6467

spec/ruby/command_line/dash_upper_w_spec.rb

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,26 @@
1919
it_behaves_like :command_line_verbose, "-W2"
2020
end
2121

22-
# Regarding the defaults, see core/warning/element_reference_spec.rb
23-
ruby_version_is "2.7" do
24-
describe "The -W command line option with :deprecated" do
25-
it "enables deprecation warnings" do
26-
ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n"
27-
end
22+
describe "The -W command line option with :deprecated" do
23+
it "enables deprecation warnings" do
24+
ruby_exe('p Warning[:deprecated]', options: '-W:deprecated').should == "true\n"
2825
end
26+
end
2927

30-
describe "The -W command line option with :no-deprecated" do
31-
it "suppresses deprecation warnings" do
32-
ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n"
33-
end
28+
describe "The -W command line option with :no-deprecated" do
29+
it "suppresses deprecation warnings" do
30+
ruby_exe('p Warning[:deprecated]', options: '-w -W:no-deprecated').should == "false\n"
3431
end
32+
end
3533

36-
describe "The -W command line option with :experimental" do
37-
it "enables experimental warnings" do
38-
ruby_exe('p Warning[:experimental]', options: '-W:experimental').should == "true\n"
39-
end
34+
describe "The -W command line option with :experimental" do
35+
it "enables experimental warnings" do
36+
ruby_exe('p Warning[:experimental]', options: '-W:experimental').should == "true\n"
4037
end
38+
end
4139

42-
describe "The -W command line option with :no-experimental" do
43-
it "suppresses experimental warnings" do
44-
ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n"
45-
end
40+
describe "The -W command line option with :no-experimental" do
41+
it "suppresses experimental warnings" do
42+
ruby_exe('p Warning[:experimental]', options: '-w -W:no-experimental').should == "false\n"
4643
end
4744
end

spec/ruby/command_line/dash_w_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
describe "The -w command line option" do
55
it_behaves_like :command_line_verbose, "-w"
66

7-
ruby_version_is "2.7" do
8-
it "enables both deprecated and experimental warnings" do
9-
ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n"
10-
end
7+
it "enables both deprecated and experimental warnings" do
8+
ruby_exe('p Warning[:deprecated]; p Warning[:experimental]', options: '-w').should == "true\ntrue\n"
119
end
1210
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
p "abc".object_id == "abc".object_id
1+
p "abc".equal?("abc")

spec/ruby/command_line/rubyopt_spec.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,22 @@
5959
ruby_exe("p $VERBOSE", escape: true).chomp.should == "true"
6060
end
6161

62-
ruby_version_is "2.7" do
63-
it "suppresses deprecation warnings for '-W:no-deprecated'" do
64-
ENV["RUBYOPT"] = '-W:no-deprecated'
65-
result = ruby_exe('$; = ""', args: '2>&1')
66-
result.should == ""
67-
end
62+
it "suppresses deprecation warnings for '-W:no-deprecated'" do
63+
ENV["RUBYOPT"] = '-W:no-deprecated'
64+
result = ruby_exe('$; = ""', args: '2>&1')
65+
result.should == ""
66+
end
6867

69-
it "suppresses experimental warnings for '-W:no-experimental'" do
70-
ENV["RUBYOPT"] = '-W:no-experimental'
71-
result = ruby_exe('case 0; in a; end', args: '2>&1')
72-
result.should == ""
73-
end
68+
it "suppresses experimental warnings for '-W:no-experimental'" do
69+
ENV["RUBYOPT"] = '-W:no-experimental'
70+
result = ruby_exe('case 0; in a; end', args: '2>&1')
71+
result.should == ""
72+
end
7473

75-
it "suppresses deprecation and experimental warnings for '-W:no-deprecated -W:no-experimental'" do
76-
ENV["RUBYOPT"] = '-W:no-deprecated -W:no-experimental'
77-
result = ruby_exe('case ($; = ""); in a; end', args: '2>&1')
78-
result.should == ""
79-
end
74+
it "suppresses deprecation and experimental warnings for '-W:no-deprecated -W:no-experimental'" do
75+
ENV["RUBYOPT"] = '-W:no-deprecated -W:no-experimental'
76+
result = ruby_exe('case ($; = ""); in a; end', args: '2>&1')
77+
result.should == ""
8078
end
8179

8280
it "requires the file for '-r'" do

spec/ruby/core/array/clear_spec.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,10 @@
2020
a.size.should == 0
2121
end
2222

23-
ruby_version_is ''...'2.7' do
24-
it "keeps tainted status" do
25-
a = [1]
26-
a.taint
27-
a.tainted?.should be_true
28-
a.clear
29-
a.tainted?.should be_true
30-
end
31-
end
32-
3323
it "does not accept any arguments" do
3424
-> { [1].clear(true) }.should raise_error(ArgumentError)
3525
end
3626

37-
ruby_version_is ''...'2.7' do
38-
it "keeps untrusted status" do
39-
a = [1]
40-
a.untrust
41-
a.untrusted?.should be_true
42-
a.clear
43-
a.untrusted?.should be_true
44-
end
45-
end
46-
4727
it "raises a FrozenError on a frozen array" do
4828
a = [1]
4929
a.freeze

0 commit comments

Comments
 (0)