-
Notifications
You must be signed in to change notification settings - Fork 227
mutex_m support #2115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mutex_m support #2115
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ def run_rbs_collection(*commands, bundler:) | |
| rbs_path << (":" + rblib) | ||
| end | ||
|
|
||
| Open3.capture3({ "RUBYLIB" => rbs_path }, *bundle_exec, "#{__dir__}/../../exe/rbs", "collection", *commands, chdir: Dir.pwd) | ||
| Open3.capture3({ "RUBYLIB" => rbs_path }, *bundle_exec, "#{__dir__}/../../exe/rbs", "--log-level=debug", "collection", *commands, chdir: Dir.pwd) | ||
| end | ||
|
|
||
| if block_given? | ||
|
|
@@ -55,7 +55,11 @@ def bundle_install(*gems) | |
| if gem == :gemspec | ||
| "gemspec" | ||
| else | ||
| "gem '#{gem}'" | ||
| if gem.is_a?(Array) | ||
| "gem #{gem.map(&:inspect).join(", ")}" | ||
| else | ||
| "gem '#{gem}'" | ||
| end | ||
| end | ||
| end | ||
|
|
||
|
|
@@ -1288,6 +1292,260 @@ def test_collection_install_gemspec | |
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__config__bundled | ||
| Dir.mktmpdir do |dir| | ||
| Dir.chdir(dir) do | ||
| dir = Pathname(dir) | ||
|
|
||
| (dir + 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: mutex_m | ||
| YAML | ||
|
|
||
| bundle_install(["mutex_m", ">= 0.3.0"]) | ||
| _stdout, stderr = run_rbs_collection("install", bundler: true) | ||
|
|
||
| refute_match(/`mutex_m` as a stdlib in rbs-gem is deprecated./, stderr) | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Rubygems, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__config__no_bundled | ||
| Dir.mktmpdir do |dir| | ||
| Dir.chdir(dir) do | ||
| dir = Pathname(dir) | ||
|
|
||
| (dir + 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: mutex_m | ||
| YAML | ||
|
|
||
| bundle_install(["mutex_m", "0.2.0"]) | ||
| _stdout, stderr = run_rbs_collection("install", bundler: true) | ||
|
|
||
| assert_include stderr, '`mutex_m` as a stdlib in rbs-gem is deprecated.' | ||
| assert_include stderr, 'Add `mutex_m` (>= 0.3.0) to the dependency of your Ruby program to use the gem-bundled type definition.' | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__config__stdlib_source | ||
| Dir.mktmpdir do |dir| | ||
| Dir.chdir(dir) do | ||
| dir = Pathname(dir) | ||
|
|
||
| (dir + 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: mutex_m | ||
| source: | ||
| type: stdlib | ||
| YAML | ||
|
|
||
| bundle_install | ||
| _stdout, stderr = run_rbs_collection("install", bundler: true) | ||
|
|
||
| assert_include stderr, '`mutex_m` as a stdlib in rbs-gem is deprecated.' | ||
| assert_include stderr, 'Add `mutex_m` (>= 0.3.0) to the dependency of your Ruby program to use the gem-bundled type definition.' | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__bundled | ||
| Dir.mktmpdir do |dir| | ||
| Dir.chdir(dir) do | ||
| dir = Pathname(dir) | ||
|
|
||
| (dir + 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')} | ||
| YAML | ||
|
|
||
| bundle_install(["mutex_m", ">= 0.3.0"]) | ||
| _stdout, stderr = run_rbs_collection("install", bundler: true) | ||
|
|
||
| refute_match(/`mutex_m` as a stdlib in rbs-gem is deprecated./, stderr) | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Rubygems, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__no_bundled | ||
| Dir.mktmpdir do |dir| | ||
| Dir.chdir(dir) do | ||
| dir = Pathname(dir) | ||
|
|
||
| (dir + 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')} | ||
| YAML | ||
|
|
||
| bundle_install(["mutex_m", "0.2.0"]) | ||
| _stdout, stderr = run_rbs_collection("install", bundler: true) | ||
|
|
||
| assert_include stderr, '`mutex_m` as a stdlib in rbs-gem is deprecated.' | ||
| assert_include stderr, 'Add `mutex_m` (>= 0.3.0) to the dependency of your Ruby program to use the gem-bundled type definition.' | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__dependency_no_bundled | ||
| 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: mutex_m | ||
| YAML | ||
|
|
||
| bundle_install("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, '`mutex_m` is included in the RBS dependencies of `true_string`, but the type definition as a stdlib in rbs-gem is deprecated.' | ||
| assert_include stderr, 'Add `mutex_m` (>= 0.3.0) to the dependency of your Ruby program to use the gem-bundled type definition.' | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Stdlib, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_collection_install__mutex_m__rbs_dependency_and__gem_dependency | ||
| Dir.mktmpdir do |dir| | ||
| Dir.chdir(dir) do | ||
| dir = Pathname(dir) | ||
|
|
||
| (dir/"gem").mkpath | ||
| (dir/"gem/hola.gemspec").write(<<~RUBY) | ||
| Gem::Specification.new do |s| | ||
| s.name = "hola" | ||
| s.version = "0.0.0" | ||
| s.summary = "Hola!" | ||
| s.description = "A simple hello world gem" | ||
| s.authors = ["Nick Quaranto"] | ||
| s.email = "[email protected]" | ||
| s.files = ["lib/hola.rb", "sig/hola.rbs"] | ||
| s.homepage = | ||
| "https://rubygems.org/gems/hola" | ||
| s.license = "MIT" | ||
| s.add_runtime_dependency "mutex_m", ">= 0.3.0" | ||
| end | ||
| RUBY | ||
| (dir/"gem/sig").mkpath | ||
| (dir/"gem/sig/manifest.yaml").write(<<~YAML) | ||
| dependencies: | ||
| - name: mutex_m | ||
| YAML | ||
|
|
||
| bundle_install(["hola", { path: "gem" }]) | ||
|
|
||
| (dir + 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')} | ||
| YAML | ||
|
|
||
| _stdout, stderr = run_rbs_collection("install", bundler: true) | ||
|
|
||
| assert_include stderr, '`mutex_m` is included in the RBS dependencies of `hola`, but the type definition as a stdlib in rbs-gem is deprecated.' | ||
| assert_include stderr, 'Delete `mutex_m` from the RBS dependencies of `hola`.' | ||
|
|
||
| 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_instance_of RBS::Collection::Sources::Rubygems, lockfile.gems["mutex_m"][:source] | ||
| end | ||
| end | ||
| end | ||
|
|
||
| def test_subtract | ||
| Dir.mktmpdir do |dir| | ||
| dir = Pathname(dir) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is
INFOmessage because the end-user is not responsible for thedependencies:of the type definition.