Skip to content
Open
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
7 changes: 7 additions & 0 deletions lib/rbs/collection/config/lockfile_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ def generate
lockfile.gems[name] = { name: name, version: "0", source: source }
end
return
when 'set', 'pathname'
# set and pathname is migrated to core from stdlib.
RBS.logger.info {
from = from_gem || "rbs_collection.yaml"
"`#{name}` is a part of the Ruby core library. The dependency to the library can be safely deleted from #{from}."
}
return
when *ALUMNI_STDLIBS.keys
version = ALUMNI_STDLIBS.fetch(name)
if from_gem
Expand Down
80 changes: 80 additions & 0 deletions test/rbs/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,86 @@ def test_collection_install__mutex_m__rbs_dependency_and__gem_dependency
end
end

def test_collection_install__pathname_set
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
dir = Pathname(dir)
dir.join(RBS::Collection::Config::PATH).write(<<~YAML)
sources:
- name: ruby/gem_rbs_collection
remote: https://github.com/ruby/gem_rbs_collection.git
revision: b4d3b346d9657543099a35a1fd20347e75b8c523
repo_dir: gems

path: #{dir.join('gem_rbs_collection')}

gems:
- name: pathname
- name: set
- name: ast
- name: cgi-escape
YAML

bundle_install('ast', 'logger')
_stdout, stderr = run_rbs_collection("install", bundler: true)

assert_include stderr, 'Cannot find `pathname` gem.'
assert_include stderr, 'Cannot find `set` gem.'

lockfile = RBS::Collection::Config::Lockfile.from_lockfile(
lockfile_path: dir + "rbs_collection.lock.yaml",
data: YAML.safe_load((dir + "rbs_collection.lock.yaml").read)
)

assert_nil lockfile.gems["set"]
assert_nil lockfile.gems["pathname"]
assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["cgi-escape"][:source]
assert_instance_of RBS::Collection::Sources::Git, lockfile.gems["ast"][:source]
end
end
end

def test_collection_install__set_pathname__manifest
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
dir = Pathname(dir)

(dir + RBS::Collection::Config::PATH).write(<<~YAML)
sources:
- type: local
path: repo

path: #{dir.join('gem_rbs_collection')}
YAML

(dir/"repo/true_string/0").mkpath
(dir/"repo/true_string/0/manifest.yaml").write(<<~YAML)
dependencies:
- name: set
- name: pathname
- name: cgi-escape
YAML

bundle_install("logger", "true_string") # true_string is a soutaro's gem that doesn't have sig directory

_stdout, stderr = run_rbs_collection("install", bundler: true)

assert_include stderr, '`set` is a part of the Ruby core library.'
assert_include stderr, '`pathname` is a part of the Ruby core library.'

lockfile = RBS::Collection::Config::Lockfile.from_lockfile(
lockfile_path: dir + "rbs_collection.lock.yaml",
data: YAML.safe_load((dir + "rbs_collection.lock.yaml").read)
)

assert_nil lockfile.gems["set"]
assert_nil lockfile.gems["pathname"]
assert_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["cgi-escape"][:source]
assert_instance_of RBS::Collection::Sources::Local, lockfile.gems["true_string"][:source]
end
end
end

def test_subtract
Dir.mktmpdir do |dir|
dir = Pathname(dir)
Expand Down