Skip to content

Commit 0e633b8

Browse files
committed
[GR-14806] Update specs
PullRequest: truffleruby/3885
2 parents 3bc31fc + 14de92b commit 0e633b8

File tree

416 files changed

+2611
-9234
lines changed

Some content is hidden

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

416 files changed

+2611
-9234
lines changed

spec/mspec/spec/runner/context_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def example.example(state, spec)
914914

915915
it "raises an Exception if unable to find the shared ContextState" do
916916
expect(MSpec).to receive(:retrieve_shared).and_return(nil)
917-
expect { @state.it_should_behave_like "this" }.to raise_error(Exception)
917+
expect { @state.it_should_behave_like :this }.to raise_error(Exception)
918918
end
919919

920920
describe "for nested ContextState instances" do

spec/mspec/tool/remove_old_guards.rb

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,51 @@ def remove_guards(guard, keep)
4646
end
4747
end
4848

49+
def remove_empty_files
50+
each_spec_file do |file|
51+
unless file.include?("fixtures/")
52+
lines = File.readlines(file)
53+
if lines.all? { |line| line.chomp.empty? or line.start_with?('require', '#') }
54+
puts "Removing empty file #{file}"
55+
File.delete(file)
56+
end
57+
end
58+
end
59+
end
60+
61+
def remove_unused_shared_specs
62+
shared_groups = {}
63+
# Dir["**/shared/**/*.rb"].each do |shared|
64+
each_spec_file do |shared|
65+
next if File.basename(shared) == 'constants.rb'
66+
contents = File.binread(shared)
67+
found = false
68+
contents.scan(/^\s*describe (:[\w_?]+), shared: true do$/) {
69+
shared_groups[$1] = 0
70+
found = true
71+
}
72+
if !found and shared.include?('shared/') and !shared.include?('fixtures/') and !shared.end_with?('/constants.rb')
73+
puts "no shared describe in #{shared} ?"
74+
end
75+
end
76+
77+
each_spec_file do |file|
78+
contents = File.binread(file)
79+
contents.scan(/(?:it_behaves_like|it_should_behave_like) (:[\w_?]+)[,\s]/) do
80+
puts $1 unless shared_groups.key?($1)
81+
shared_groups[$1] += 1
82+
end
83+
end
84+
85+
shared_groups.each_pair do |group, value|
86+
if value == 0
87+
puts "Shared describe #{group} seems unused"
88+
elsif value == 1
89+
puts "Shared describe #{group} seems used only once" if $VERBOSE
90+
end
91+
end
92+
end
93+
4994
def search(regexp)
5095
each_spec_file do |file|
5196
contents = File.binread(file)
@@ -64,7 +109,11 @@ def search(regexp)
64109
version += "(?:\\.0)?" if version.count(".") < 2
65110
remove_guards(/ruby_version_is (["'])#{version}\1 do/, true)
66111
remove_guards(/ruby_version_is (["'])[0-9.]*\1 *... *(["'])#{version}\2 do/, false)
67-
remove_guards(/ruby_bug "#\d+", (["'])[0-9.]*\1 *... *(["'])#{version}\2 do/, true)
112+
remove_guards(/ruby_bug ["']#\d+["'], (["'])[0-9.]*\1 *... *(["'])#{version}\2 do/, true)
113+
114+
remove_empty_files
115+
remove_unused_shared_specs
68116

117+
puts "Search:"
69118
search(/(["'])#{version}\1/)
70119
search(/^\s*#.+#{version}/)

spec/ruby/.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4-
TargetRubyVersion: 2.7
4+
TargetRubyVersion: 3.0
55
DisplayCopNames: true
66
Exclude:
77
- command_line/fixtures/bad_syntax.rb

spec/ruby/CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ Here is a list of the most commonly-used guards:
138138
#### Version guards
139139

140140
```ruby
141-
ruby_version_is ""..."2.6" do
142-
# Specs for RUBY_VERSION < 2.6
141+
ruby_version_is ""..."3.2" do
142+
# Specs for RUBY_VERSION < 3.2
143143
end
144144

145-
ruby_version_is "2.6" do
146-
# Specs for RUBY_VERSION >= 2.6
145+
ruby_version_is "3.2" do
146+
# Specs for RUBY_VERSION >= 3.2
147147
end
148148
```
149149

@@ -191,11 +191,11 @@ end
191191
#### Combining guards
192192

193193
```ruby
194-
guard -> { platform_is :windows and ruby_version_is ""..."2.6" } do
195-
# Windows and RUBY_VERSION < 2.6
194+
guard -> { platform_is :windows and ruby_version_is ""..."3.2" } do
195+
# Windows and RUBY_VERSION < 3.2
196196
end
197197

198-
guard_not -> { platform_is :windows and ruby_version_is ""..."2.6" } do
198+
guard_not -> { platform_is :windows and ruby_version_is ""..."3.2" } do
199199
# The opposite
200200
end
201201
```

spec/ruby/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ ruby/spec is known to be tested in these implementations for every commit:
3030
* [Opal](https://github.com/opal/opal/tree/master/spec)
3131
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)
3232

33-
ruby/spec describes the behavior of Ruby 2.7 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.7.x, 3.0.x, 3.1.x, etc), and those are tested in CI.
33+
ruby/spec describes the behavior of Ruby 3.0 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 (3.0.x, 3.1.x, 3.2.x, etc), and those are tested in CI.
3535

3636
### Synchronization with Ruby Implementations
3737

@@ -61,6 +61,7 @@ For older specs try these commits:
6161
* Ruby 2.4.10 - [Suite](https://github.com/ruby/spec/commit/bce4f2b81d6c31db67cf4d023a0625ceadde59bd) using [MSpec](https://github.com/ruby/mspec/commit/e7eb8aa4c26495b7b461e687d950b96eb08b3ff2)
6262
* Ruby 2.5.9 - [Suite](https://github.com/ruby/spec/commit/c503335d3d9f6ec6ef24de60a0716c34af69b64f) using [MSpec](https://github.com/ruby/mspec/commit/0091e8a62e954717cd54641f935eaf1403692041)
6363
* Ruby 2.6.10 - [Suite](https://github.com/ruby/spec/commit/aaf998fb8c92c4e63ad423a2e7ca6e6921818c6e) using [MSpec](https://github.com/ruby/mspec/commit/5e36c684e9e2b92b1187589bba1df22c640a8661)
64+
* Ruby 2.7.8 - [Suite](https://github.com/ruby/spec/commit/93787e6035c925b593a9c0c6fb0e7e07a6f1df1f) using [MSpec](https://github.com/ruby/mspec/commit/1d8cf64722d8a7529f7cd205be5f16a89b7a67fd)
6465

6566
### Running the specs
6667

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,46 @@
11
require_relative '../spec_helper'
22

3-
ruby_version_is "3.0" do
4-
describe "The --backtrace-limit command line option" do
5-
it "limits top-level backtraces to a given number of entries" do
6-
file = fixture(__FILE__ , "backtrace.rb")
7-
out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1)
8-
out = out.gsub(__dir__, '')
3+
describe "The --backtrace-limit command line option" do
4+
it "limits top-level backtraces to a given number of entries" do
5+
file = fixture(__FILE__ , "backtrace.rb")
6+
out = ruby_exe(file, options: "--backtrace-limit=2", args: "top 2>&1", exit_status: 1)
7+
out = out.gsub(__dir__, '')
98

10-
out.should == <<-MSG
9+
out.should == <<-MSG
1110
top
1211
/fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
1312
\tfrom /fixtures/backtrace.rb:6:in `b'
1413
\tfrom /fixtures/backtrace.rb:10:in `c'
1514
\t ... 2 levels...
16-
MSG
17-
end
15+
MSG
16+
end
1817

19-
it "affects Exception#full_message" do
20-
file = fixture(__FILE__ , "backtrace.rb")
21-
out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1")
22-
out = out.gsub(__dir__, '')
18+
it "affects Exception#full_message" do
19+
file = fixture(__FILE__ , "backtrace.rb")
20+
out = ruby_exe(file, options: "--backtrace-limit=2", args: "full_message 2>&1")
21+
out = out.gsub(__dir__, '')
2322

24-
out.should == <<-MSG
23+
out.should == <<-MSG
2524
full_message
2625
/fixtures/backtrace.rb:2:in `a': oops (RuntimeError)
2726
\tfrom /fixtures/backtrace.rb:6:in `b'
2827
\tfrom /fixtures/backtrace.rb:10:in `c'
2928
\t ... 2 levels...
30-
MSG
31-
end
29+
MSG
30+
end
3231

33-
it "does not affect Exception#backtrace" do
34-
file = fixture(__FILE__ , "backtrace.rb")
35-
out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1")
36-
out = out.gsub(__dir__, '')
32+
it "does not affect Exception#backtrace" do
33+
file = fixture(__FILE__ , "backtrace.rb")
34+
out = ruby_exe(file, options: "--backtrace-limit=2", args: "backtrace 2>&1")
35+
out = out.gsub(__dir__, '')
3736

38-
out.should == <<-MSG
37+
out.should == <<-MSG
3938
backtrace
4039
/fixtures/backtrace.rb:2:in `a'
4140
/fixtures/backtrace.rb:6:in `b'
4241
/fixtures/backtrace.rb:10:in `c'
4342
/fixtures/backtrace.rb:14:in `d'
4443
/fixtures/backtrace.rb:29:in `<main>'
45-
MSG
46-
end
44+
MSG
4745
end
4846
end

spec/ruby/core/argf/bytes_spec.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

spec/ruby/core/argf/chars_spec.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

spec/ruby/core/argf/codepoints_spec.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

spec/ruby/core/argf/lines_spec.rb

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)