Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
GIT
remote: https://github.com/soutaro/steep.git
revision: 727014c361ae996a80b87948510c83ca480f5e82
revision: 35bb7dc667a709d999105fe78b534b819afef6d7
specs:
steep (2.1.0.dev)
steep (2.1.0.dev.1)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
fileutils (>= 1.1.0)
Expand Down Expand Up @@ -55,14 +55,14 @@ GEM
benchmark (0.5.0)
benchmark-ips (2.15.1)
bigdecimal (4.1.2)
concurrent-ruby (1.3.6)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
csv (3.3.5)
csv (3.3.6)
dbm (1.1.0)
diff-lcs (1.6.2)
digest (3.2.1)
drb (2.2.3)
erb (6.0.6)
erb (6.0.7)
extconf_compile_commands_json (0.0.7)
ffi (1.17.4)
fileutils (1.8.0)
Expand All @@ -71,19 +71,19 @@ GEM
psych (>= 3.1, < 5.0)
rainbow (>= 3.0, < 4.0)
strong_json (>= 1.1, < 2.2)
i18n (1.14.8)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.8.2)
io-console (0.9.1)
irb (1.18.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.19.7)
json (2.21.2)
json-schema (6.2.0)
addressable (~> 2.8)
bigdecimal (>= 3.1, < 5)
language_server-protocol (3.17.0.5)
language_server-protocol (3.17.0.6)
lint_roller (1.1.0)
listen (3.10.0)
logger
Expand All @@ -101,14 +101,14 @@ GEM
timeout
net-smtp (0.5.1)
net-protocol
nkf (0.2.0)
nkf (0.3.0)
ostruct (0.6.3)
parallel (2.1.0)
parser (3.3.11.1)
parser (3.3.12.0)
ast (~> 2.4.1)
racc
power_assert (3.0.1)
pp (0.6.3)
pp (0.6.4)
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
Expand All @@ -134,7 +134,7 @@ GEM
rbs (>= 4.0.0)
tsort
regexp_parser (2.12.0)
reline (0.6.3)
reline (0.7.0)
io-console (~> 0.5)
rspec (3.13.2)
rspec-core (~> 3.13.0)
Expand All @@ -149,7 +149,7 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.7)
rubocop (1.87.0)
rubocop (1.89.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand All @@ -160,7 +160,7 @@ GEM
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.1)
rubocop-ast (1.50.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-on-rbs (2.0.0)
Expand All @@ -180,7 +180,7 @@ GEM
tempfile (0.3.1)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
test-unit (3.7.7)
test-unit (3.7.8)
power_assert
timeout (0.6.1)
tsort (0.2.0)
Expand Down
12 changes: 5 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,11 @@ namespace :generate do
class TestTemplateBuilder
attr_reader :target, :env

def initialize(target)
def initialize(target, paths:)
@target = target

loader = RBS::EnvironmentLoader.new
Dir['stdlib/*'].each do |lib|
next if lib.end_with?('builtin')

loader.add(library: File.basename(lib))
end
paths.each { loader.add(path: Pathname(_1)) }
@env = RBS::Environment.from_loader(loader).resolve_type_names
end

Expand Down Expand Up @@ -425,7 +421,7 @@ namespace :generate do
end
end

path.write TestTemplateBuilder.new(target).call
path.write TestTemplateBuilder.new(target, paths: args.extras).call

puts "Created: #{path}"
end
Expand All @@ -436,6 +432,8 @@ task :test_generate_stdlib do
sh "ruby -c /tmp/Array_test.rb"
sh "RBS_GENERATE_TEST_PATH=/tmp/Thread_Mutex_test.rb rake 'generate:stdlib_test[Thread::Mutex]'"
sh "ruby -c /tmp/Thread_Mutex_test.rb"
sh "RBS_GENERATE_TEST_PATH=/tmp/Kconv_test.rb rake 'generate:stdlib_test[Kconv,stdlib/nkf/0,stdlib/kconv/0]'"
sh "ruby -c /tmp/Kconv_test.rb"
end

# Pull requests with one of these labels are omitted from the changelog.
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You will typically follow the steps as follows:

1. Run `rbs prototype runtime` to generate list of methods.
2. Run `rbs annotate` to import RDoc comments.
3. Run `rake generate:stdlib_test[LIB]` to generate a test case.
3. Run `rake generate:stdlib_test[CLASS,PATH,...]` to generate a test case. Pass the paths to the standard library signatures and their dependencies when needed.
4. Write the type definitions and tests.

See the next *Useful Tools* section and the guides above for writing and testing RBS files.
Expand Down
8 changes: 8 additions & 0 deletions docs/stdlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ $ bundle exec rake 'generate:stdlib_test[String]'
Created: test/stdlib/String_test.rb
```

Core signatures are loaded by default. To generate a test for a class defined in standard library signatures,
pass the paths containing those signatures and their dependencies after the class name.

```console
$ bundle exec rake 'generate:stdlib_test[CSV::Row,stdlib/csv/0,stdlib/forwardable/0]'
Created: test/stdlib/CSV_Row_test.rb
```

It generates `test/stdlib/[class_name]_test.rb`.
The test scripts would look like the following:

Expand Down
18 changes: 9 additions & 9 deletions steep/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (8.1.3)
activesupport (8.1.3.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
Expand All @@ -17,16 +17,16 @@ GEM
ast (2.4.3)
base64 (0.3.0)
bigdecimal (4.1.2)
concurrent-ruby (1.3.6)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
csv (3.3.5)
csv (3.3.6)
drb (2.2.3)
ffi (1.17.4)
fileutils (1.8.0)
i18n (1.14.8)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
json (2.19.9)
language_server-protocol (3.17.0.5)
json (2.21.2)
language_server-protocol (3.17.0.6)
listen (3.10.0)
logger
rb-fsevent (~> 0.10, >= 0.10.3)
Expand All @@ -36,7 +36,7 @@ GEM
drb (~> 2.0)
prism (~> 1.5)
mutex_m (0.3.0)
parser (3.3.11.1)
parser (3.3.12.0)
ast (~> 2.4.1)
racc
power_assert (3.0.1)
Expand All @@ -49,7 +49,7 @@ GEM
rbs (3.10.4)
logger
tsort
ruby-lsp (0.26.9)
ruby-lsp (0.26.10)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 5)
Expand All @@ -74,7 +74,7 @@ GEM
strscan (3.1.8)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
test-unit (3.7.7)
test-unit (3.7.8)
power_assert
tsort (0.2.0)
tzinfo (2.0.6)
Expand Down
Loading