rbs 0.10.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +9 -9
- data/CHANGELOG.md +29 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +16 -6
- data/Steepfile +28 -0
- data/bin/steep +4 -0
- data/bin/test_runner.rb +7 -5
- data/docs/syntax.md +14 -1
- data/lib/rbs/ast/comment.rb +7 -1
- data/lib/rbs/ast/declarations.rb +15 -9
- data/lib/rbs/ast/members.rb +3 -8
- data/lib/rbs/buffer.rb +1 -1
- data/lib/rbs/cli.rb +72 -3
- data/lib/rbs/constant.rb +1 -1
- data/lib/rbs/constant_table.rb +9 -8
- data/lib/rbs/definition.rb +31 -14
- data/lib/rbs/definition_builder.rb +97 -67
- data/lib/rbs/environment.rb +28 -11
- data/lib/rbs/environment_loader.rb +67 -47
- data/lib/rbs/location.rb +1 -5
- data/lib/rbs/method_type.rb +5 -5
- data/lib/rbs/namespace.rb +14 -3
- data/lib/rbs/parser.y +2 -12
- data/lib/rbs/prototype/rb.rb +3 -5
- data/lib/rbs/prototype/rbi.rb +1 -4
- data/lib/rbs/prototype/runtime.rb +0 -4
- data/lib/rbs/substitution.rb +4 -3
- data/lib/rbs/test/setup.rb +5 -1
- data/lib/rbs/test/setup_helper.rb +15 -0
- data/lib/rbs/test/tester.rb +7 -5
- data/lib/rbs/test/type_check.rb +14 -2
- data/lib/rbs/type_name.rb +18 -1
- data/lib/rbs/type_name_resolver.rb +10 -3
- data/lib/rbs/types.rb +27 -21
- data/lib/rbs/variance_calculator.rb +9 -6
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +26 -17
- data/sig/annotation.rbs +26 -0
- data/sig/buffer.rbs +28 -0
- data/sig/builtin_names.rbs +41 -0
- data/sig/comment.rbs +26 -0
- data/sig/constant.rbs +21 -0
- data/sig/constant_table.rbs +30 -0
- data/sig/declarations.rbs +202 -0
- data/sig/definition.rbs +129 -0
- data/sig/definition_builder.rbs +94 -0
- data/sig/environment.rbs +94 -0
- data/sig/environment_loader.rbs +58 -0
- data/sig/location.rbs +52 -0
- data/sig/members.rbs +160 -0
- data/sig/method_types.rbs +40 -0
- data/sig/namespace.rbs +124 -0
- data/sig/polyfill.rbs +3 -0
- data/sig/rbs.rbs +3 -0
- data/sig/substitution.rbs +39 -0
- data/sig/type_name_resolver.rbs +24 -0
- data/sig/typename.rbs +70 -0
- data/sig/types.rbs +361 -0
- data/sig/util.rbs +13 -0
- data/sig/variance_calculator.rbs +35 -0
- data/sig/version.rbs +3 -0
- data/sig/writer.rbs +40 -0
- data/stdlib/bigdecimal/big_decimal.rbs +887 -0
- data/stdlib/bigdecimal/math/big_math.rbs +142 -0
- data/stdlib/builtin/array.rbs +2 -1
- data/stdlib/builtin/builtin.rbs +0 -3
- data/stdlib/builtin/hash.rbs +1 -1
- data/stdlib/builtin/kernel.rbs +2 -0
- data/stdlib/builtin/math.rbs +26 -26
- data/stdlib/builtin/struct.rbs +9 -10
- data/stdlib/date/date.rbs +1056 -0
- data/stdlib/date/date_time.rbs +582 -0
- data/stdlib/forwardable/forwardable.rbs +204 -0
- data/stdlib/pathname/pathname.rbs +2 -0
- data/stdlib/pty/pty.rbs +5 -29
- data/stdlib/set/set.rbs +1 -1
- data/stdlib/uri/file.rbs +167 -0
- data/stdlib/uri/generic.rbs +875 -0
- data/stdlib/uri/http.rbs +158 -0
- data/stdlib/uri/https.rbs +108 -0
- data/stdlib/uri/ldap.rbs +224 -0
- data/stdlib/uri/ldaps.rbs +108 -0
- data/stdlib/zlib/zlib.rbs +1 -1
- data/steep/Gemfile +3 -0
- data/steep/Gemfile.lock +51 -0
- metadata +45 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9e733e8a7ed63c585d2a2253728700a7cdca633fd6a7953fb95cda24f423604
|
4
|
+
data.tar.gz: e690e3412cc614e0ce7d8c379e78f2d39d5a2def56f2e7165322db7c421cffd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87bcb3459cb7ef4ac2e56f1047064e0d2b7412d19023ae63b1329e8e40a1dcff3ce3766cfc1086c8447aa2b2e4aea5207e1bf901b25c3f3d49072d90f5a6c694
|
7
|
+
data.tar.gz: 916e9bb2f678fa321862700f386b09b7de88a127e7d4ba92d9b6139f030a865db18a976e51a5820b84caa4c6598aafda876c5e7183a3ed3ff19b8054cfa16842
|
data/.github/workflows/ruby.yml
CHANGED
@@ -15,20 +15,20 @@ jobs:
|
|
15
15
|
- master-nightly-bionic
|
16
16
|
- 2.6.5-bionic
|
17
17
|
- 2.7.0-bionic
|
18
|
+
job:
|
19
|
+
- test
|
20
|
+
- stdlib_test
|
21
|
+
- rubocop validate test_doc build test_generate_stdlib
|
18
22
|
container:
|
19
23
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
20
24
|
steps:
|
21
25
|
- uses: actions/checkout@v1
|
22
|
-
- name:
|
26
|
+
- name: Install
|
23
27
|
run: |
|
24
28
|
ruby -v
|
25
29
|
gem install bundler
|
26
30
|
bin/setup
|
27
|
-
|
28
|
-
|
29
|
-
bundle exec rake
|
30
|
-
|
31
|
-
bundle exec rake test_doc
|
32
|
-
bundle exec rake build
|
33
|
-
RBS_GENERATE_TEST_PATH=/tmp/Array_test.rb bundle exec rake 'generate:stdlib_test[Array]'
|
34
|
-
ruby -c /tmp/Array_test.rb
|
31
|
+
- name: Run test
|
32
|
+
run: |
|
33
|
+
bundle exec rake ${{ matrix.job }}
|
34
|
+
if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6.5'))"
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,35 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.13.0 (2020-09-09)
|
6
|
+
|
7
|
+
* Signature updates for `URI` classes.
|
8
|
+
* Fix tests ([#410](https://github.com/ruby/rbs/pull/410))
|
9
|
+
* Add `--silent` option for `rbs validate` ([#411](https://github.com/ruby/rbs/pull/411))
|
10
|
+
|
11
|
+
## 0.12.2 (2020-09-17)
|
12
|
+
|
13
|
+
* Minor signature update for `pty`
|
14
|
+
* Fix `PTY` stdlib test
|
15
|
+
|
16
|
+
## 0.12.1 (2020-09-16)
|
17
|
+
|
18
|
+
This version is to improve Ruby 3 testing compatibility. Nothing changed for users.
|
19
|
+
|
20
|
+
## 0.12.0 (2020-09-15)
|
21
|
+
|
22
|
+
* Signature updates for `forwardable`, `struct`, `set`, `URI::Generic`, `URI::File`, and `BigDecimal`.
|
23
|
+
* Define `.new` methods from `initialize` included from modules [#390](https://github.com/ruby/rbs/pull/390)
|
24
|
+
|
25
|
+
## 0.11.0 (2020-08-31)
|
26
|
+
|
27
|
+
* Signature update for `date/datetime` [#367](https://github.com/ruby/rbs/pull/367)
|
28
|
+
* Add test double support for runtime type checker [#380](https://github.com/ruby/rbs/pull/380)
|
29
|
+
* Add `rbs test` command for runtime type checking [#366](https://github.com/ruby/rbs/pull/366)
|
30
|
+
* Fix runtime type checking for record types [#365](https://github.com/ruby/rbs/pull/365)
|
31
|
+
* Improve EnvironmentLoader API [#370](https://github.com/ruby/rbs/pull/370)
|
32
|
+
* Allow overloading from super methods [#364](https://github.com/ruby/rbs/pull/364)
|
33
|
+
|
5
34
|
## 0.10.0 (2020-08-10)
|
6
35
|
|
7
36
|
* Signature update for `Zlib`
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -123,7 +123,7 @@ puts singleton.methods[:gsub]
|
|
123
123
|
|
124
124
|
## Development
|
125
125
|
|
126
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
126
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
127
127
|
|
128
128
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
129
129
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
|
+
require "rbconfig"
|
4
|
+
|
5
|
+
ruby = ENV["RUBY"] || RbConfig.ruby
|
6
|
+
rbs = File.join(__dir__, "exe/rbs")
|
7
|
+
bin = File.join(__dir__, "bin")
|
3
8
|
|
4
9
|
Rake::TestTask.new(:test) do |t|
|
5
10
|
t.libs << "test"
|
@@ -16,23 +21,23 @@ task :test_doc => :parser do
|
|
16
21
|
`git ls-files -z`.split("\x0").select do |file| Pathname(file).extname == ".md" end
|
17
22
|
end
|
18
23
|
|
19
|
-
sh "ruby bin/run_in_md.rb #{files.join(" ")}"
|
24
|
+
sh "#{ruby} #{__dir__}/bin/run_in_md.rb #{files.join(" ")}"
|
20
25
|
end
|
21
26
|
|
22
27
|
task :validate => :parser do
|
23
|
-
sh "rbs validate"
|
28
|
+
sh "#{ruby} #{rbs} validate --silent"
|
24
29
|
|
25
30
|
FileList["stdlib/*"].each do |path|
|
26
31
|
next if path =~ %r{stdlib/builtin}
|
27
|
-
sh "rbs -r#{File.basename(path)} validate"
|
32
|
+
sh "#{ruby} #{rbs} -r#{File.basename(path)} validate --silent"
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
36
|
FileList["test/stdlib/**/*_test.rb"].each do |test|
|
32
|
-
|
33
|
-
sh "ruby bin/test_runner.rb #{test}"
|
37
|
+
task test => :parser do
|
38
|
+
sh "#{ruby} -Ilib #{bin}/test_runner.rb #{test}"
|
34
39
|
end
|
35
|
-
|
40
|
+
task stdlib_test: test
|
36
41
|
end
|
37
42
|
|
38
43
|
task :rubocop do
|
@@ -171,4 +176,9 @@ namespace :generate do
|
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
179
|
+
task :test_generate_stdlib do
|
180
|
+
sh "RBS_GENERATE_TEST_PATH=/tmp/Array_test.rb rake 'generate:stdlib_test[Array]'"
|
181
|
+
sh "ruby -c /tmp/Array_test.rb"
|
182
|
+
end
|
183
|
+
|
174
184
|
CLEAN.include("lib/rbs/parser.rb")
|
data/Steepfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
target :lib do
|
2
|
+
signature "sig"
|
3
|
+
check "lib"
|
4
|
+
|
5
|
+
vendor stdlib: "stdlib"
|
6
|
+
library "set", "pathname", "json", "logger"
|
7
|
+
end
|
8
|
+
|
9
|
+
# target :lib do
|
10
|
+
# signature "sig"
|
11
|
+
#
|
12
|
+
# check "lib" # Directory name
|
13
|
+
# check "Gemfile" # File name
|
14
|
+
# check "app/models/**/*.rb" # Glob
|
15
|
+
# # ignore "lib/templates/*.rb"
|
16
|
+
#
|
17
|
+
# # library "pathname", "set" # Standard libraries
|
18
|
+
# # library "strong_json" # Gems
|
19
|
+
# end
|
20
|
+
|
21
|
+
# target :spec do
|
22
|
+
# signature "sig", "sig-private"
|
23
|
+
#
|
24
|
+
# check "spec"
|
25
|
+
#
|
26
|
+
# # library "pathname", "set" # Standard libraries
|
27
|
+
# # library "rspec"
|
28
|
+
# end
|
data/bin/steep
ADDED
data/bin/test_runner.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
$LOAD_PATH << File.join(__dir__, "../lib")
|
4
|
+
|
5
|
+
IS_RUBY_27 = Gem::Version.new(RUBY_VERSION).yield_self do |ruby_version|
|
6
|
+
Gem::Version.new('2.7.0') <= ruby_version &&
|
7
|
+
ruby_version <= Gem::Version.new('2.8.0')
|
5
8
|
end
|
6
9
|
|
7
|
-
unless
|
8
|
-
STDERR.puts "
|
9
|
-
exit
|
10
|
+
unless IS_RUBY_27
|
11
|
+
STDERR.puts "⚠️⚠️⚠️⚠️ stdlib test assumes Ruby 2.7 but RUBY_VERSION==#{RUBY_VERSION} ⚠️⚠️⚠️⚠️"
|
10
12
|
end
|
11
13
|
|
12
14
|
ARGV.each do |arg|
|
data/docs/syntax.md
CHANGED
@@ -212,7 +212,7 @@ _method-type_ ::= `(` _parameters_ `) ->` _type_
|
|
212
212
|
|
213
213
|
_parameters_ ::= _required-positionals_ _optional-positionals_ _rest-positional_ _trailing-positionals_ _keywords_
|
214
214
|
|
215
|
-
|
215
|
+
_parameter_ ::= _type_ _var-name_ # Parameter with var name
|
216
216
|
| _type_ # Parameter without var name
|
217
217
|
_required-positionals_ ::= _parameter_ `,` ...
|
218
218
|
_optional-positionals_ ::= `?` _parameter_ `,` ...
|
@@ -529,3 +529,16 @@ You can declare a global variable.
|
|
529
529
|
$LOAD_PATH: Array[String]
|
530
530
|
```
|
531
531
|
|
532
|
+
### Comments
|
533
|
+
|
534
|
+
You can write single line comments. Comments must be on their own line. Comments can lead with whitespace.
|
535
|
+
|
536
|
+
```
|
537
|
+
# This if interface Foo
|
538
|
+
# Usage of Foo is bar
|
539
|
+
interface _Foo
|
540
|
+
# New foo is a method
|
541
|
+
# it will return foo.
|
542
|
+
def new: () -> Foo
|
543
|
+
end
|
544
|
+
```
|
data/lib/rbs/ast/comment.rb
CHANGED
data/lib/rbs/ast/declarations.rb
CHANGED
@@ -7,7 +7,7 @@ module RBS
|
|
7
7
|
class ModuleTypeParams
|
8
8
|
attr_reader :params
|
9
9
|
|
10
|
-
TypeParam = Struct.new(:name, :variance, :skip_validation, keyword_init: true) do
|
10
|
+
TypeParam = _ = Struct.new(:name, :variance, :skip_validation, keyword_init: true) do
|
11
11
|
def to_json(*a)
|
12
12
|
{
|
13
13
|
name: name,
|
@@ -47,7 +47,11 @@ module RBS
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def each(&block)
|
50
|
-
|
50
|
+
if block
|
51
|
+
params.each(&block)
|
52
|
+
else
|
53
|
+
params.each
|
54
|
+
end
|
51
55
|
end
|
52
56
|
|
53
57
|
def self.empty
|
@@ -55,11 +59,13 @@ module RBS
|
|
55
59
|
end
|
56
60
|
|
57
61
|
def variance(name)
|
58
|
-
self[name]
|
62
|
+
var = self[name] or raise
|
63
|
+
var.variance
|
59
64
|
end
|
60
65
|
|
61
66
|
def skip_validation?(name)
|
62
|
-
self[name]
|
67
|
+
var = self[name] or raise
|
68
|
+
var.skip_validation
|
63
69
|
end
|
64
70
|
|
65
71
|
def empty?
|
@@ -85,7 +91,7 @@ module RBS
|
|
85
91
|
if block_given?
|
86
92
|
members.each do |member|
|
87
93
|
if member.is_a?(Members::Base)
|
88
|
-
yield member
|
94
|
+
yield(_ = member)
|
89
95
|
end
|
90
96
|
end
|
91
97
|
else
|
@@ -96,8 +102,8 @@ module RBS
|
|
96
102
|
def each_decl
|
97
103
|
if block_given?
|
98
104
|
members.each do |member|
|
99
|
-
if member.is_a?(
|
100
|
-
yield member
|
105
|
+
if member.is_a?(Base)
|
106
|
+
yield(_ = member)
|
101
107
|
end
|
102
108
|
end
|
103
109
|
else
|
@@ -108,9 +114,9 @@ module RBS
|
|
108
114
|
|
109
115
|
module MixinHelper
|
110
116
|
def each_mixin(&block)
|
111
|
-
if
|
117
|
+
if block
|
112
118
|
@mixins ||= begin
|
113
|
-
members.select do |member|
|
119
|
+
_ = members.select do |member|
|
114
120
|
case member
|
115
121
|
when Members::Include, Members::Extend, Members::Prepend
|
116
122
|
true
|
data/lib/rbs/ast/members.rb
CHANGED
@@ -11,17 +11,15 @@ module RBS
|
|
11
11
|
attr_reader :annotations
|
12
12
|
attr_reader :location
|
13
13
|
attr_reader :comment
|
14
|
-
attr_reader :attributes
|
15
14
|
attr_reader :overload
|
16
15
|
|
17
|
-
def initialize(name:, kind:, types:, annotations:, location:, comment:,
|
16
|
+
def initialize(name:, kind:, types:, annotations:, location:, comment:, overload:)
|
18
17
|
@name = name
|
19
18
|
@kind = kind
|
20
19
|
@types = types
|
21
20
|
@annotations = annotations
|
22
21
|
@location = location
|
23
22
|
@comment = comment
|
24
|
-
@attributes = attributes
|
25
23
|
@overload = overload
|
26
24
|
end
|
27
25
|
|
@@ -30,14 +28,13 @@ module RBS
|
|
30
28
|
other.name == name &&
|
31
29
|
other.kind == kind &&
|
32
30
|
other.types == types &&
|
33
|
-
other.attributes == attributes &&
|
34
31
|
other.overload == overload
|
35
32
|
end
|
36
33
|
|
37
34
|
alias eql? ==
|
38
35
|
|
39
36
|
def hash
|
40
|
-
self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^
|
37
|
+
self.class.hash ^ name.hash ^ kind.hash ^ types.hash ^ overload.hash
|
41
38
|
end
|
42
39
|
|
43
40
|
def instance?
|
@@ -52,7 +49,7 @@ module RBS
|
|
52
49
|
overload
|
53
50
|
end
|
54
51
|
|
55
|
-
def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment,
|
52
|
+
def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload)
|
56
53
|
self.class.new(
|
57
54
|
name: name,
|
58
55
|
kind: kind,
|
@@ -60,7 +57,6 @@ module RBS
|
|
60
57
|
annotations: annotations,
|
61
58
|
location: location,
|
62
59
|
comment: comment,
|
63
|
-
attributes: attributes,
|
64
60
|
overload: overload
|
65
61
|
)
|
66
62
|
end
|
@@ -73,7 +69,6 @@ module RBS
|
|
73
69
|
annotations: annotations,
|
74
70
|
location: location,
|
75
71
|
comment: comment,
|
76
|
-
attributes: attributes,
|
77
72
|
overload: overload
|
78
73
|
}.to_json(*a)
|
79
74
|
end
|
data/lib/rbs/buffer.rb
CHANGED
data/lib/rbs/cli.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require "open3"
|
1
2
|
require "optparse"
|
3
|
+
require "shellwords"
|
2
4
|
|
3
5
|
module RBS
|
4
6
|
class CLI
|
@@ -36,7 +38,7 @@ module RBS
|
|
36
38
|
@stderr = stderr
|
37
39
|
end
|
38
40
|
|
39
|
-
COMMANDS = [:ast, :list, :ancestors, :methods, :method, :validate, :constant, :paths, :prototype, :vendor, :parse]
|
41
|
+
COMMANDS = [:ast, :list, :ancestors, :methods, :method, :validate, :constant, :paths, :prototype, :vendor, :parse, :test]
|
40
42
|
|
41
43
|
def library_parse(opts, options:)
|
42
44
|
opts.on("-r LIBRARY", "Load RBS files of the library") do |lib|
|
@@ -382,6 +384,11 @@ Examples:
|
|
382
384
|
|
383
385
|
$ rbs validate
|
384
386
|
EOU
|
387
|
+
|
388
|
+
opts.on("--silent") do
|
389
|
+
require "stringio"
|
390
|
+
@stdout = StringIO.new
|
391
|
+
end
|
385
392
|
end.parse!(args)
|
386
393
|
|
387
394
|
loader = EnvironmentLoader.new()
|
@@ -487,7 +494,7 @@ Show paths to directories where the RBS files are loaded from.
|
|
487
494
|
Examples:
|
488
495
|
|
489
496
|
$ rbs paths
|
490
|
-
$
|
497
|
+
$ rbs -r set paths
|
491
498
|
EOU
|
492
499
|
end.parse!(args)
|
493
500
|
|
@@ -542,7 +549,7 @@ EOU
|
|
542
549
|
Usage: rbs prototype runtime [options...] [pattern...]
|
543
550
|
|
544
551
|
Generate RBS prototype based on runtime introspection.
|
545
|
-
It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].
|
552
|
+
It loads Ruby code specified in [options] and generates RBS prototypes for classes matches to [pattern].
|
546
553
|
|
547
554
|
Examples:
|
548
555
|
|
@@ -750,5 +757,67 @@ Examples:
|
|
750
757
|
TypeName.new(name: last, namespace: namespace.parent)
|
751
758
|
end
|
752
759
|
end
|
760
|
+
|
761
|
+
def test_opt options
|
762
|
+
opt_string = options.dirs.map { |dir| "-I #{Shellwords.escape(dir)}"}.concat(options.libs.map { |lib| "-r#{Shellwords.escape(lib)}"}).join(' ')
|
763
|
+
opt_string.empty? ? nil : opt_string
|
764
|
+
end
|
765
|
+
|
766
|
+
def run_test(args, options)
|
767
|
+
unchecked_classes = []
|
768
|
+
targets = []
|
769
|
+
sample_size = nil
|
770
|
+
double_suite = nil
|
771
|
+
|
772
|
+
(opts = OptionParser.new do |opts|
|
773
|
+
opts.banner = <<EOB
|
774
|
+
Usage: rbs [rbs options...] test [test options...] COMMAND
|
775
|
+
|
776
|
+
Examples:
|
777
|
+
|
778
|
+
$ rbs test rake test
|
779
|
+
$ rbs --log-level=debug test --target SomeModule::* rspec
|
780
|
+
$ rbs test --target SomeModule::* --target AnotherModule::* --target SomeClass rake test
|
781
|
+
|
782
|
+
Options:
|
783
|
+
EOB
|
784
|
+
opts.on("--target TARGET", "Sets the runtime test target") do |target|
|
785
|
+
targets << target
|
786
|
+
end
|
787
|
+
|
788
|
+
opts.on("--sample-size SAMPLE_SIZE", "Sets the sample size") do |size|
|
789
|
+
sample_size = size
|
790
|
+
end
|
791
|
+
|
792
|
+
opts.on("--unchecked-class UNCHECKED_CLASS", "Sets the class that would not be checked") do |unchecked_class|
|
793
|
+
unchecked_classes << unchecked_class
|
794
|
+
end
|
795
|
+
|
796
|
+
opts.on("--double-suite DOUBLE_SUITE", "Sets the double suite in use (currently supported: rspec | minitest)") do |suite|
|
797
|
+
double_suite = suite
|
798
|
+
end
|
799
|
+
|
800
|
+
end).order!(args)
|
801
|
+
|
802
|
+
if args.length.zero?
|
803
|
+
stdout.puts opts.help
|
804
|
+
exit 1
|
805
|
+
end
|
806
|
+
|
807
|
+
env_hash = {
|
808
|
+
'RUBYOPT' => "#{ENV['RUBYOPT']} -rrbs/test/setup",
|
809
|
+
'RBS_TEST_OPT' => test_opt(options),
|
810
|
+
'RBS_TEST_LOGLEVEL' => RBS.logger_level,
|
811
|
+
'RBS_TEST_SAMPLE_SIZE' => sample_size,
|
812
|
+
'RBS_TEST_DOUBLE_SUITE' => double_suite,
|
813
|
+
'RBS_TEST_UNCHECKED_CLASSES' => (unchecked_classes.join(',') unless unchecked_classes.empty?),
|
814
|
+
'RBS_TEST_TARGET' => (targets.join(',') unless targets.empty?)
|
815
|
+
}
|
816
|
+
|
817
|
+
out, err, status = Open3.capture3(env_hash, *args)
|
818
|
+
stdout.print(out)
|
819
|
+
stderr.print(err)
|
820
|
+
status
|
821
|
+
end
|
753
822
|
end
|
754
823
|
end
|