Skip to content

Commit

Permalink
Merge branch 'master' into gem-rbs-load
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Jan 24, 2024
2 parents 50225e6 + e81d4c2 commit 9de6aec
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 72 deletions.
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ gem "dbm"
gem 'digest'
gem 'tempfile'
gem "rdoc"
gem "bigdecimal"
gem "abbrev"
gem "base64"
gem "mutex_m"
gem "nkf"
gem "fileutils"

# Test gems
gem "rbs-amber", path: "test/assets/test-gem"
Expand Down
11 changes: 11 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ GEM
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
dbm (1.1.0)
diff-lcs (1.5.0)
digest (3.1.1)
fileutils (1.7.2)
goodcheck (3.1.0)
marcel (>= 1.0, < 2.0)
psych (>= 3.1, < 5.0)
Expand All @@ -30,10 +33,12 @@ GEM
language_server-protocol (3.17.0.3)
marcel (1.0.2)
minitest (5.21.2)
mutex_m (0.2.0)
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-protocol
nkf (0.2.0)
parallel (1.24.0)
parser (3.3.0.4)
ast (~> 2.4.1)
Expand Down Expand Up @@ -94,13 +99,19 @@ PLATFORMS
x86_64-darwin-20

DEPENDENCIES
abbrev
base64
bigdecimal
dbm
digest
fileutils
goodcheck
json
json-schema
minitest
mutex_m
net-smtp
nkf
rake
rake-compiler
rbs!
Expand Down
2 changes: 1 addition & 1 deletion stdlib/fileutils/0/fileutils.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,5 +1771,5 @@ module FileUtils
#
# Related: FileUtils.touch.
#
def self?.uptodate?: (path new, pathlist old_list) -> bool
def self?.uptodate?: (path new, _Each[path] old_list) -> bool
end
91 changes: 28 additions & 63 deletions test/rbs/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,31 @@ def run_rbs_collection(*commands, bundler:)
[stdout, stderr]
end

def bundle_install(*gems)
stdout, stderr, status =
Bundler.with_unbundled_env do
gems = gems.map do |gem|
if gem == :gemspec
"gemspec"
else
"gem '#{gem}'"
end
end

(Pathname(Dir.pwd) + "Gemfile").write(<<~RUBY)
source "https://rubygems.org"
#{gems.join("\n")}
RUBY

Open3.capture3("bundle", "install", chdir: Dir.pwd)
end

assert_predicate status, :success?, stderr

[stdout, stderr]
end

def with_cli
orig_logger_output = RBS.logger_output
RBS.logger_output = stdout
Expand Down Expand Up @@ -972,26 +997,8 @@ def test_collection_install
path: #{dir.join('gem_rbs_collection')}
YAML
dir.join('Gemfile').write(<<~GEMFILE)
source 'https://rubygems.org'
gem 'ast'
GEMFILE
dir.join('Gemfile.lock').write(<<~LOCK)
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
PLATFORMS
x86_64-linux
DEPENDENCIES
ast
BUNDLED WITH
2.2.0
LOCK

bundle_install('ast', 'abbrev', 'bigdecimal')
_stdout, _stderr = run_rbs_collection("install", bundler: true)

rbs_collection_lock = dir.join('rbs_collection.lock.yaml')
Expand Down Expand Up @@ -1056,26 +1063,8 @@ def test_collection_update
path: #{dir.join('gem_rbs_collection')}
YAML
dir.join('Gemfile').write(<<~GEMFILE)
source 'https://rubygems.org'
gem 'ast'
GEMFILE
dir.join('Gemfile.lock').write(<<~LOCK)
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
PLATFORMS
x86_64-linux
DEPENDENCIES
ast
BUNDLED WITH
2.2.0
LOCK

bundle_install('ast', 'abbrev', 'bigdecimal')
run_rbs_collection("update", bundler: true)

assert dir.join('rbs_collection.lock.yaml').exist?
Expand All @@ -1097,31 +1086,6 @@ def test_collection_install_gemspec
path: #{dir.join('gem_rbs_collection')}
YAML
dir.join('Gemfile').write(<<~GEMFILE)
source 'https://rubygems.org'
gemspec
GEMFILE
dir.join('Gemfile.lock').write(<<~LOCK)
PATH
remote: .
specs:
hola (0.0.0)
ast (>= 2)
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
PLATFORMS
arm64-darwin-22
DEPENDENCIES
hola!
BUNDLED WITH
2.2.0
LOCK
gemspec_path = dir / "hola.gemspec"
gemspec_path.write <<~RUBY
Gem::Specification.new do |s|
Expand All @@ -1140,6 +1104,7 @@ def test_collection_install_gemspec
RUBY
(dir/"sig").mkdir

bundle_install(:gemspec, "abbrev", "bigdecimal")
stdout, _ = run_rbs_collection("install", bundler: true)

assert_match(/Installing ast:(\d(\.\d)*)/, stdout)
Expand Down
13 changes: 5 additions & 8 deletions test/stdlib/FileUtils_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,8 @@ def test_touch
end

def test_uptodate?
assert_send_type "(String, String) -> bool",
FileUtils, :uptodate?, "foo", "bar"
assert_send_type "(String, Array[String | ToStr | ToPath]) -> bool",
FileUtils, :uptodate?, "foo", ["bar", ToStr.new("bar"), ToPath.new("bar")]
assert_send_type "(ToStr, ToStr) -> bool",
FileUtils, :uptodate?, ToStr.new("foo"), ToStr.new("bar")
assert_send_type "(ToPath, ToPath) -> bool",
FileUtils, :uptodate?, ToPath.new("foo"), ToPath.new("bar")
end
end

Expand Down Expand Up @@ -970,7 +964,10 @@ def test_touch
end

def test_uptodate?
assert_send_type "(String, String) -> bool",
Foo.new, :uptodate?, "foo", "bar"
in_tmpdir do
FileUtils.touch "foo"
assert_send_type "(String, Array[String]) -> bool",
Foo.new, :uptodate?, "foo", ["bar"]
end
end
end

0 comments on commit 9de6aec

Please sign in to comment.